這也是一種比較推薦的寫法,不會(huì)產(chǎn)生離屏渲染問(wèn)題
- (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;
}
效果

上半部分圓角.png