简体   繁体   English

iOS中两个Label的圆角

[英]Rounded Corner of two Label in ios

I have two label left and right mentioned . 我有两个标签左右提及。 Now i am trying to rounded the corner from left of left label and right of right label 现在我想从左标签的左边和右标签的右边弄圆角

I have tried this: 我已经试过了:

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

(this code is also not working all border are rounded ..) (此代码也无法正常工作,所有边框均四舍五入..)

cell.rightLabel.layer.cornerRadius = 8;

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

Set the property clipsToBounds to YES or use MasksToBounds to YES 将属性clipsToBounds设置为YES或使用MasksToBoundsYES

cell.rightLabel.clipsToBounds = YES;
cell.leftlabel.clipsToBounds = YES;

try this 尝试这个

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;

Try this : 尝试这个 :

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;

i hope its work..... 我希望它的工作.....

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM