iOS8,UILabel实现圆角

来源:互联网 发布:vb实例150例 函数调用 编辑:程序博客网 时间:2024/06/16 07:50

直接通过layer的cornerRadius属性,设置圆角,发现在iOS8下显示错误(故意设置了红色边框,看得清楚)



虽然边框是圆角,但是UILabel本身还是直角

在iOS8下,需要这样写:

cancelLabel.layer.cornerRadius = 5.f;cancelLabel.layer.borderColor = [UIColor whiteColor].CGColor;// 设置成UILabel的背景色[cancelLabel.layer setMasksToBounds:YES];// 关键

效果:


0 0
原创粉丝点击