为视图添加部分边角

JPLabel(继承UILabel)

@implementation JPLabel

-(void)layoutSubviews{

[superlayoutSubviews];

UIBezierPath*maskPath = [UIBezierPathbezierPathWithRoundedRect:CGRectMake(0,0,self.frame.size.width,self.frame.size.height)byRoundingCorners:UIRectCornerBottomRight|UIRectCornerTopRight cornerRadii:CGSizeMake(self.frame.size.height*0.5,self.frame.size.height*0.5)];

CAShapeLayer*maskLayer = [[CAShapeLayeralloc]init];

maskLayer.frame=self.bounds;

maskLayer.path= maskPath.CGPath;

self.layer.mask= maskLayer;

}

@end

你可能感兴趣的:(为视图添加部分边角)