How to make a simple rounded button in Storyboard?

Gintas_ picture Gintas_ · Aug 10, 2016 · Viewed 114.8k times · Source

I just started learning iOS development, cannot find how to make simple rounded button. I find resources for old versions. Do I need to set a custom background for a button? In Android, I would just use a 9 patch, but I know iOS does not have this capability.

enter image description here

Answer

Nishant picture Nishant · Aug 10, 2016

Short Answer: YES

You can absolutely make a simple rounded button without the need of an additional background image or writing any code for the same. Just follow the screenshot given below, to set the runtime attributes for the button, to get the desired result.

It won't show in the Storyboard but it will work fine when you run the project.

enter image description here

Note:
The 'Key Path' layer.cornerRadius and value is 5. The value needs to be changed according to the height and width of the button. The formula for it is the height of button * 0.50. So play around the value to see the expected rounded button in the simulator or on the physical device. This procedure will look tedious when you have more than one button to be rounded in the storyboard.