layer.cornerRadius = 30
clipsToBounds = true
To generate round corners on such a button, if you set the
cornerRadius value to
30, you are assuming that the height of the button is set to
This may not be true on all the devices, depending on how you handle your layout. Seeing your image, it looks like the button is slightly less high than what you designed.
Two options :
60, so your button always has a height of 60 points.
UIButtonsubclass, and in the
layoutSubviewsmethod, set the
cornerRadiusto half the height of the
boundsof your button. This way, any time the system re-draws the button, the corner radius will be updated appropriately.