在开发中, 控件的圆角使用还是很频繁的, 其实圆角设置也比较简单
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
[btn setFrame:CGRectMake(100, 100, 100, 100)];
btn.backgroundColor = [UIColor redColor];
btn.layer.cornerRadius = 50.0;//设置圆角
[self.view addSubview:btn];
这样就可以设置成圆角, 但是如果在button上添加图片就会发现图片是不会随着button变成圆角
btn.layer.masksToBounds = YES;
这时就要添加这句代码进行设置, 否则控件是圆不起来得.