swift - iOS SDK: Corner Radius shows incorrectly -


here i've got screen designed in sketch:

enter image description here

there 2 buttons. designing such button in xcode , setting uibutton's corner radius way:

layer.cornerradius = 30 clipstobounds = true 

but result having strange:

enter image description here

you can see corner in center if left , right sides of button. can do?

to generate round corners on such button, if set cornerradius value 30, assuming height of button set 60.

this may not true on devices, depending on how handle layout. seeing image, looks button less high designed.

two options :

  1. use auto-layout , add constraint of "fixed height" on button, value of 60, button has height of 60 points.
  2. implement uibutton subclass, , in layoutsubviews method, set cornerradius half height of bounds of button. way, time system re-draws button, corner radius updated appropriately.

Comments