How to create a round button?

前端 未结 10 1531
刺人心
刺人心 2020-12-02 09:33

I want to create a round circular button. This button should look like a circle.

This code gives round rectangular button.

UIButton *button = [UIBut         


        
10条回答
  •  無奈伤痛
    2020-12-02 09:59

    Try this, it worked for me. It will make your button or any view in circular shape only if you have taken it in square i.e width should be equals to height.

    yourButton.layer.cornerRadius = yourButton.bounds.size.width/2;
    

提交回复
热议问题