How to round the corners of a button

前端 未结 15 679
隐瞒了意图╮
隐瞒了意图╮ 2020-12-07 06:54

I have a rectangle image (jpg) and want to use it to fill the background of a button with rounded corner in xcode.

I wrote the following:

UIButton *b         


        
15条回答
  •  遥遥无期
    2020-12-07 07:25

    I tried the following solution with the UITextArea and I expect this will work with UIButton as well.

    First of all import this in your .m file -

    #import 
    

    and then in your loadView method add following lines

        yourButton.layer.cornerRadius = 10; // this value vary as per your desire
        yourButton.clipsToBounds = YES;
    

提交回复
热议问题