Ios 使用CAShapeLayer时最小化屏幕外渲染

Ios 使用CAShapeLayer时最小化屏幕外渲染,ios,core-animation,Ios,Core Animation,非常标准的设置:VC view通过CAShapeLayer和UIBezierPath圆角,如下所示: UIBezierPath *cornerPath = [UIBezierPath bezierPathWithRoundedRect:self.view.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight

非常标准的设置:VC view通过CAShapeLayer和UIBezierPath圆角,如下所示:

UIBezierPath *cornerPath = [UIBezierPath bezierPathWithRoundedRect:self.view.bounds
                                                 byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight
                                                       cornerRadii:CGSizeMake(4, 4)];
CAShapeLayer *maskLayer = [CAShapeLayer layer];
maskLayer.frame = self.view.bounds;
maskLayer.path = cornerPath.CGPath;
self.view.layer.mask = maskLayer;

虽然这样做有效,但它会导致整个视图被渲染到屏幕外,当然应该有一种方法来至少最小化对角的渲染,甚至消除这种渲染?

您是否尝试将shapelayer添加为子层而不是遮罩?遮罩通常会导致屏幕外渲染。如果遮罩很大,但遮罩面积很小,则成本可能会很高。遮罩内容后面可见哪些内容?然后只需在所有内容的顶部添加黑色“反向”切角。