iOS之任意圆角
2017-02-28 本文已影响23人
张大普奔
例如给一个view加圆角:
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
CGFloat corner = 6;
CAShapeLayer *shapeLayer = [CAShapeLayer layer];
shapeLayer.path = [UIBezierPath bezierPathWithRoundedRect:view.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight | UIRectCornerBottomLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(corner, corner)].CGPath;
view.layer.mask = shapeLayer;