Search code examples
iosuibuttoninterface-builderios7xcode5

No Round Rect Button in Xcode 5?


Is drag and drop of round rect button no longer available in Xcode 5? I can't seem to find it in the Interface Builder. I was guessing that this is one of the changes in iOS 7, but I just wanted to make sure.


Solution

  • The Round Rect button from Xcode 4 and previous versions appears to have been replaced with the System Default button, which also happens to be clear. I.e. by default there is no white background with rounded corners, only the text is visible.

    To make the button white (or any other colour), select the attributes inspector and scroll down to the View section:

    enter image description here

    Select Background and change it to White:

    enter image description here

    If you want rounded corners you can do so with a little bit of code. Just ctrl-drag from the button to your .h file, call it something like roundedButton and add this in your viewDidLoad:

    CALayer *btnLayer = [roundedButton layer];
    [btnLayer setMasksToBounds:YES];
    [btnLayer setCornerRadius:5.0f];