这也是一种比较推荐的写法,不会产生离屏渲染问题
- (void)setupCornerRadius
{
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, KSCREEN_WIDTH, 450)
byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight
cornerRadii:CGSizeMake(12, 12)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = self.contentView.bounds;
maskLayer.path = maskPath.CGPath;
self.contentView.layer.mask = maskLayer;
}
效果

网友评论