How to create a round button?

前端 未结 10 1526
刺人心
刺人心 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:41

    In Xcode 7.0.0 on IOS 8 this code works perfectly for me. Provided the length and height of button frame is same.

    myButton.clipsToBounds = YES;
    myButton.layer.cornerRadius = myButton.layer.frame.size.width/2;
    

提交回复
热议问题