Rounded corner buttons in iOS7, and Landscape by default

I’ve been struggling with how to make rounded corner buttons in iOS7 for ages now, and finally worked it out. It’s actually pretty easy – but fairly well hidden as usual.

I’ve also been trying to figure out how to to put the view controllers into Landscape mode.

So this is a post in two parts. landscape view controllers, and rounded UIButtons.

1, this is not using images, nor background images of any type. It’s just using the plain vanilla UIButton that comes with the standard XCode 5.1.1, and iOS7.1 SDK.

This is also a note for me for future reference as well.

You can test it out easily. Make a Test app. Call it errr, TestApp. You can set it up as a Universal if you like. Practice on both iPhone and iPad interfaces.

Firstly: Landscape view controller.

Click on the black bar just to the bottom of the actual view controller. This will cause the view controller and the bar to have a blue surrounding.

Now, click on the little shield fourth to the right in the top right hand side. The Show Attribute Inspector.

Set Orientation to Landscape. Don’t touch anything else. In this example I have already Embedded the view controller in a Navigation Controller so the rest of the app will work…

It’s done.

Image

 

Now, for the buttons. Note here, that the buttons DO NOT appear to be rounded when sitting in the viewcontroller. It’s only when compiled and running in the Simulator/Device that they are reounded. See the later screen shot.

Click on the Main_iPhone.storyboard and there, drag a UIButton into the view controller.

Still with the Attribute Inspector selected, change the button type to Custom. Note I set the button background to a purple colour so I can clearly see the shape when it runs.

Image

Now this bit isa bit trickier. Take your time with this.

With the button still selected, click on the little button Third from the left in the top tab bar, next to the Attribute inspector, called Identity Inspector. Not the Very top right row, the second top right row, it looks kind of like a tiny screen layout? Look in the image following here.

With the Button selected in the view controller – (Not the ViewController, or you will have a view controller with rounded corners. Not at all bad I guess … but not what we want here.)

Select in Custom Class -> Class -> UIButton. (If you don’t find it in the list from the drop-down, type it in… then look again.) I had to fiddle with this a bit to get it to appear.

Once you have UIButton in the Class field, time to do the next bit.

You have to add information to the “User Defined Runtime Attributes” by tapping the + button for that section.

Don’t be dismayed by what you see there, it’s a place holder. Double click the KeyPath and change it to what you see here in the image.

layer.cornerRadius          Number    10
layer.masksToBounds     Boolean    tick

Nothing will change, but when you run the app in the simulator – there is your rounded button.

Image

enjoy

Posted in iOS | Leave a comment

Video recording in Landscape mode only

Exploring Video Recording in Landscape Mode only, using AVCam from Apple for iOS

There are a lot of nice tutorials out there, but they are all in Portrait mode. Now I ask you – do you turn your 55″ Wide Screen TV on it’s side so you can watch X-Men in Portrait mode? Not even…. So I’m trying to force my Video app into Landscape ONLY mode. Experimenting with Apple’s AVCam code, available here on the development site. So far. this is what I’ve done. In the AVCam project settings, removed all but Orientation Left. Un-tick the boxes. I only want Orientation Left. I also want it to RECORD in Orientation Left, in the file AVCamViewController.m, about line 160 or there abouts,

AVCaptureMovieFileOutput *movieFileOutput = [[AVCaptureMovieFileOutput alloc] init];
 if ([session canAddOutput:movieFileOutput])
 {
 [session addOutput:movieFileOutput];

 // I added this bracket block
 AVCaptureConnection *connection = [movieFileOutput connectionWithMediaType:AVMediaTypeVideo];
 if ([connection isVideoOrientationSupported])
 {
 AVCaptureVideoOrientation orientation = AVCaptureVideoOrientationLandscapeLeft;
 [connection setVideoOrientation:orientation];
 }

 if ([connection isVideoStabilizationSupported])
 [connection setEnablesVideoStabilizationWhenAvailable:YES];
 [self setMovieFileOutput:movieFileOutput];
 }

 AVCaptureStillImageOutput *stillImageOutput = [[AVCaptureStillImageOutput alloc] init];
 if ([session canAddOutput:stillImageOutput])
 {
 [stillImageOutput setOutputSettings:@{AVVideoCodecKey : AVVideoCodecJPEG}];
 [session addOutput:stillImageOutput];
 [self setStillImageOutput:stillImageOutput];
 }
 });

To force the Whole session into Landscape Left mode, I had to add this bit, same file. In AVCamViewController.m, about line 235 or there a bouts.

- (NSUInteger)supportedInterfaceOrientations
{
 // I changed this from ...MaskAll to ...MaskLandscapeLeft
 return UIInterfaceOrientationMaskLandscapeLeft;
}

Now, when I start the app, it starts in LandscapeLeft mode (Home button in my left hand) and also records the video in landscape mode, as evidenced by playback in the standard iPhone Camera Roll. Now, to translate this into any video app – especially the one I’m building.

Posted in iOS | Leave a comment

Follow Me example

Using the BWS Plugin, which interferes with the Twittter code – it works in both places.
[...] with the words follow_me between the brackets

So what I’m saying, just use the basic Twitter code, or the Plugin. Not both.

 


Posted in Default Category | Leave a comment

AppCoda Tutorials

Brilliant stuff. You need to visit the site. www.appcoda.com

 

Posted in iOS | Leave a comment

How to enter code into a WordPress post

-(instancetype)initWithDatabaseFilename:(NSString *)dbFilename{
    self = [super init];
    if (self) {

    }
    return self;
}

pre class="brush: c; highlight: [5, 15]"

Posted in Default Category | Leave a comment