猫猫学iOS之UILabel设置圆角不成功所做调控更改

原创文章。欢迎转载。转载请注明:翟乃玉的博客
地址:http://blog.csdn.net/u013357243

如图问题

如图是我要做的效果这里写图片描写叙述

然而当我写好代码后,设置号label的layer圆角后是这种
这里写图片描写叙述
崩溃。。

解决

百度后知道解决方法。原来少了一行代码

            cell.textLabel.text = @"检查更新";
            UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(NYScreenW - 145, 9, 115, 30)];
            label.layer.cornerRadius = 13;
            label.backgroundColor = [UIColor grayColor];
            label.clipsToBounds = YES;
            label.text = @" 版本:2.2.22";
            [cell addSubview:label];

之前并没有些label.clipsToBounds = YES;这行代码,
当然。除了设置maskToBounds = YES 是能够的 还能够设置 clipsToBounds = YES 也能够 。

posted @ 2017-07-05 16:22  mfmdaoyou  阅读(294)  评论(0)    收藏  举报