iOS分角设置View圆角

1
2
3
4
5
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, Screen_width-30, 258) byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(2, 2)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = CGRectMake(0, 0, Screen_width-30, 258);
maskLayer.path = maskPath.CGPath;
self.picTure.layer.mask = maskLayer;
  • 注意:当分角设置View的圆角的时候要确定的知道View的绝对Frame不然会出现偏差。