How to make a simple rounded button in Storyboard?

后端 未结 13 1853
渐次进展
渐次进展 2021-01-29 19:49

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

13条回答
  •  佛祖请我去吃肉
    2021-01-29 20:01

    You can connect IBOutlet of yur button from storyboard.

    Then you can set corner radius of your button to make it's corner round.

    for example, your outlet is myButton then,

    Obj - C

     self.myButton.layer.cornerRadius = 5.0 ;
    

    Swift

      myButton.layer.cornerRadius = 5.0
    

    If you want exact round button then your button's width and height must be equal and cornerRadius must be equal to height or width / 2 (half of the width or height).

提交回复
热议问题