栅格化 CAGradientLayer 与 CGGradient 效率明智
Rasterised CAGradientLayer vs CGGradient efficiency wise
创建 CAGradientLayer 是将新的子层添加到视图的现有层(shouldRasterize
为 true
)。而 CGGradient 在 draw
方法中绘制视图。
使用一个比另一个有主要的速度优势吗?
关于 Core Graphics 的 Ray Wenderlich article 中有一条注释提到了两者的不同之处。原来两者的渲染方式有很大的不同,这是注解:
Drawing static views with Core Graphics is generally quick enough, but
if your views move around or need frequent redrawing, you should use
Core Animation layers. Core Animation is optimized so that the GPU,
not the CPU, handles most of the processing. In contrast, the CPU
processes view drawing performed by Core Graphics in draw(_:).
因为这是一般说明,所以这也适用于 CALayer
s 与 draw(_:)
。
创建 CAGradientLayer 是将新的子层添加到视图的现有层(shouldRasterize
为 true
)。而 CGGradient 在 draw
方法中绘制视图。
使用一个比另一个有主要的速度优势吗?
关于 Core Graphics 的 Ray Wenderlich article 中有一条注释提到了两者的不同之处。原来两者的渲染方式有很大的不同,这是注解:
Drawing static views with Core Graphics is generally quick enough, but if your views move around or need frequent redrawing, you should use Core Animation layers. Core Animation is optimized so that the GPU, not the CPU, handles most of the processing. In contrast, the CPU processes view drawing performed by Core Graphics in draw(_:).
因为这是一般说明,所以这也适用于 CALayer
s 与 draw(_:)
。