2017-02-28 62 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; 

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