使用前提是不能使用mansory 得使用frame布局!
1.如果是切四個角的圓角,代碼示例:
imgView.layer.cornerRadius = 8;
imgView.layer.masksToBounds = YES;
2.如果是四個角中的某幾個角,一個,兩個,或者3個,代碼示例(切的左下,和右下):
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.tipLabel.bounds byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(5, 5)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = _tipLabel.bounds;
maskLayer.path = maskPath.CGPath;
self.tipLabel.layer.mask = maskLayer;
==================================
類型共有以下幾種:
* UIRectCornerTopLeft ?//左上
* UIRectCornerTopRight ?//右上
* UIRectCornerBottomLeft ?//左下
* UIRectCornerBottomRight ?//右下
* UIRectCornerAllCorners ?//所有