Jac*_*ale 15 iphone performance animation shadow ipad
我有一个UILabel与CALayer阴影on.And我只是将它周围通过UIView动画.
性能很差,我可以看到动画根本不流畅.
我认为这是UILabel导致动画问题的阴影,因为如果我关闭阴影,动画会变得像平常一样平滑.
我试过用 view.layer.shouldRasterize = YES;
但动画表现仍然存在.
谁能给我一些提示?
谢谢
Noa*_*oon 40
通过使用其shadowPath属性,您可以极大地提高CALayer阴影的性能 - 这允许它绘制阴影而无需重新计算图层的alpha遮罩.对于矩形视图,您可以像这样使用它:
theView.layer.shadowPath = [UIBezierPath bezierPathWithRect:theView.bounds].CGPath;
Run Code Online (Sandbox Code Playgroud)
或者,如果它的角是圆的,
theView.layer.shadowPath = [UIBezierPath bezierPathWithRoundedRect:theView.bounds cornerRadius:theView.layer.cornerRadius].CGPath;
Run Code Online (Sandbox Code Playgroud)
请注意,这是视图边框周围的阴影 - 如果您希望在文本本身的阴影上获得更好的性能,则需要使用标签的文本阴影属性(这会牺牲CALayer阴影的细节,如模糊,以便更好地渲染速度)或更复杂的选项 - 创建一个CGPathRef,用作shadowPath文本字形本身的图层.
| 归档时间: |
|
| 查看次数: |
4583 次 |
| 最近记录: |