How to round the corners of a button

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

    Import QuartCore framework if it is not there in your existing project, then import #import in viewcontroller.m

    UIButton *button = [[UIButton buttonWithType:UIButtonTypeRoundedRect]];
    CGRect frame = CGRectMake(x, y, width, height); // set values as per your requirement
    button.layer.cornerRadius = 10;
    button.clipsToBounds = YES;
    

提交回复
热议问题