使用UIBezierPath给视图添加圆角
2017-03-21 本文已影响0人
蛋哥是只猫
- (UIView *)clipView:(UIView *)originView roundingCorners:(UIRectCorner)corners cornerRadii:(CGSize)cornerRadii{
UIBezierPath * maskPath = [UIBezierPath bezierPathWithRoundedRect:originView.bounds byRoundingCorners:corners cornerRadii:cornerRadii];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = originView.bounds;
maskLayer.path = maskPath.CGPath; // 轨迹
originView.layer.mask = maskLayer;
return originView;
}