使用CAShapeLayer时最大限度地减少屏幕外渲染

时间:2013-05-01 21:49:30

标签: ios core-animation

漂亮的标准设置:VC视图的顶角通过带有UIBezierPath的CAShapeLayer舍入,如下所示:

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;

虽然这有效,但它会导致整个视图在屏幕外呈现,当然应该有一种方法可以至少将渲染最小化到角落,甚至可以摆脱它?

0 个答案:

没有答案