// 左上角和右上角添加圆角
UIView *customView = [[UIView alloc] initWithFrame:CGRectMake(10, 10, 200, 300)];
UIRectCorner corner = UIRectCornerTopLeft | UIRectCornerTopRight;
UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:customView.bounds
byRoundingCorners:corner
cornerRadii:CGSizeMake(12, 12)];
CAShapeLayer *layer = [[CAShapeLayer alloc] init];
layer.frame = customView.bounds;
layer.path = path.CGPath;
customView.layer.mask = layer;
网友评论