How to round the corners of a button

前端 未结 15 693
隐瞒了意图╮
隐瞒了意图╮ 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:30

    UIButton* closeBtn = [[UIButton alloc] initWithFrame:CGRectMake(10, 50, 90, 35)];
    //Customise this button as you wish then
    closeBtn.layer.cornerRadius = 10;
    closeBtn.layer.masksToBounds = YES;//Important
    

提交回复
热议问题