2017-02-28 100 views
0

我提到了左右两个标签。 现在我试图绕过拐角从左ios中两个标签的圆角

我曾尝试这一权利:标签的左边标签,右:

cell.rightLabel.layer.cornerRadius = UIRectCornerBottomLeft | UIRectCornerTopLeft; 

(此代码还没有工作的所有边界四舍五入..)

cell.rightLabel.layer.cornerRadius = 8; 

cell.leftlabel.layer.cornerRadius = UIRectCornerBottomRight | UIRectCornerTopRight; 
    cell.leftlabel.layer.cornerRadius = 8; 

回答

1

设置属性clipsToBoundsYES或使用MasksToBoundsYES

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; 
+0

感谢@庵埠...它做工精细。但如何仅右侧标签左侧(即,左侧标签和右侧标签)右侧(右侧标签和右侧标签) – SANTOSH

+0

@SANTOSH - 检查更新后的答案 –

+0

@SANTOSH - 你的问题解决与否 –

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; 

我希望它的工作.....