ios - CAShapeLayer - 具有显式路径的性能

标签 ios performance core-animation cashapelayer

CAShapeLayer 的 CGPath 属性在 documentation 中有下面这句话:

Specifying an explicit path usually improves rendering performance.

什么是“显式”路径?设置显式路径如何提高 CAShapeLayer 的渲染性能?

设置显式路径比没有路径的性能如何更高?

最佳答案

这看起来可能是文档中的复制粘贴错误 - CALayer 的 shadowPath 属性包含类似的文本 block :

The default value of this property is nil, which causes the layer to use a standard shadow shape. If you specify a value for this property, the layer creates its shadow using the specified path instead of the layer’s composited alpha channel. The path you provide defines the outline of the shadow. It is filled using the non-zero winding rule and the current shadow color, opacity, and blur radius.

Specifying an explicit path usually improves rendering performance.

对于shadowPath,实际上有一个区别:不指定属性值会导致根据图层的合成 Alpha 计算阴影。当 CAShapeLayer 没有设置 path 时,它不会执行任何此类操作,因此您引用的文档具有误导性。

关于ios - CAShapeLayer - 具有显式路径的性能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22182092/

相关文章:

ios - 如何获取用于 SSL 固定的公钥哈希?

ios - 字典、自动释放池和临时对象

multithreading - 当线程数翻倍时,我的矩阵乘法程序需要四倍的时间

c# - 字典中按键识别速度

objective-c - 在 UIImage 中顺序移动方 block

ios - UICollectionView 仅在 Scroll 上加载图像

.net - CLR内存消耗问题

objective-c - 在相机不是场景中心的 3D 空间中对 2D 平面进行广告牌

ios - 倾斜文本后创建 UIImage

ios - 具有 3D 旋转功能的 CAEmitterCell