![](https://img.haomeiwen.com/i1208485/57222a1e5b98df07.png)
上图是目标效果;那让我们来实现吧
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同理)
网友评论