我提到左右两个标签。 现在我试图从左侧标签左侧和右侧标签右侧的角落
我试过这个:
cell.rightLabel.layer.cornerRadius = UIRectCornerBottomLeft | UIRectCornerTopLeft;
(此代码也无效,所有边框都被舍入..)
cell.rightLabel.layer.cornerRadius = 8;
cell.leftlabel.layer.cornerRadius = UIRectCornerBottomRight | UIRectCornerTopRight;
cell.leftlabel.layer.cornerRadius = 8;
答案 0 :(得分:1)
将属性clipsToBounds
设置为是或将MasksToBounds
设置为是
cell.rightLabel.clipsToBounds = YES;
cell.leftlabel.clipsToBounds = YES;
试试这个
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:cell.rightLabel.bounds byRoundingCorners:(UIRectCornerTopLeft | UIRectCornerBottomLeft ) cornerRadii:CGSizeMake(10.0, 10.0)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = cell.rightLabel.bounds;
maskLayer.path = maskPath.CGPath;
cell.rightLabel.layer.mask = maskLayer;
答案 1 :(得分:0)
试试这个:
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.label.bounds byRoundingCorners:(UIRectCornerTopLeft | UIRectCornerBottomLeft ) cornerRadii:CGSizeMake(10.0, 10.0)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = self.view.bounds;
maskLayer.path = maskPath.CGPath;
self.label.layer.mask = maskLayer;
我希望它的工作.....