// 左上和右上爲圓角
UIBezierPath *cornerRadiusPath = [UIBezierPath bezierPathWithRoundedRect:self.teLabel.bounds byRoundingCorners:UIRectCornerTopRight | UIRectCornerTopLeft cornerRadii:CGSizeMake(5, 5)];
CAShapeLayer *cornerRadiusLayer = [ [CAShapeLayer alloc] init];
cornerRadiusLayer.frame = self.teLabel.bounds;
cornerRadiusLayer.path = cornerRadiusPath.CGPath;
self.teLabel.layer.mask = cornerRadiusLayer;
要設置其他角的圓角,可以修改byRoundingCorners:
UIRectCornerTopLeft = 1 << 0, // 左上
UIRectCornerTopRight = 1 << 1, // 右上
UIRectCornerBottomLeft = 1 << 2, // 左下
UIRectCornerBottomRight = 1 << 3, // 右下