Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 932
juminoz Avatar asked Aug 22 '13 15:08

juminoz


People also ask

How do you set the corner radius of a button in Swift 4?

To get round corners button using Interface Builder add a Key Path = "layer. cornerRadius" with Type = "Number" and Value = "10" (or other value as required) in the " User Defined RunTime Attribute " of the Identity Inspector of the button.


2 Answers

Can also make the rounded rect within the storyboard.

enter image description here

like image 94
DogCoffee Avatar answered Oct 19 '22 19:10

DogCoffee


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];
like image 52
Robert Avatar answered Oct 19 '22 18:10

Robert