iOS设置view的圆角

iOS设置view的圆角_第1张图片

上图是目标效果;那让我们来实现吧

UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];

button.frame = CGRectMake(100, 200, 100, 50);

button.backgroundColor = RGBCOLOR(163, 135, 91);

[button setTitle:@"进入房间" forState:UIControlStateNormal];

[button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];

[button.layer setMasksToBounds:YES];

[button.layer setCornerRadius:button.height / 2];// 圆角角度

[button.layer setBorderWidth:1.0];// 圆角宽度

[button.layer setBorderColor:[UIColor clearColor].CGColor];// 圆角颜色

[self.view addSubview:button];

完成。(UILabel,UIImageView同理)

你可能感兴趣的:(iOS设置view的圆角)