我有两个标签 left 和 right mentioned 。 现在我正在尝试从左标签的左侧和右标签的右侧圆角
我试过这个:
cell.rightLabel.layer.cornerRadius = UIRectCornerBottomLeft | UIRectCornerTopLeft;
(此代码也无法正常工作,所有边框都是圆形的..)
cell.rightLabel.layer.cornerRadius = 8;
cell.leftlabel.layer.cornerRadius = UIRectCornerBottomRight | UIRectCornerTopRight;
cell.leftlabel.layer.cornerRadius = 8;
最佳答案
将属性 clipsToBounds
设置为 YES 或使用 MasksToBounds
为 YES
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;
关于ios - ios中两个Label的圆角,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42502584/