将view指定的角设置为圆角

UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 80, 80)]; 
view.backgroundColor = [UIColor redColor]; 
[self.view addSubview:view];

 UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:view.bounds byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(5, 5)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init]; 
maskLayer.frame = view.bounds; 
maskLayer.path = maskPath.CGPath; 
view.layer.mask = maskLayer;    
posted @ 2016-04-20 18:55  YouNeedCourage  阅读(527)  评论(0编辑  收藏  举报