码迷,mamicode.com
首页 > 其他好文 > 详细

CAShapeLayer-What Shape Layers Are

时间:2019-01-31 20:56:31      阅读:182      评论:0      收藏:0      [点我收藏+]

标签:像素   gpu   draw   depend   size   als   anim   making   nes   

矢量图、gpu直接使用、占用内存小

 

What Shape Layers Are

Shape layers are layers capable of defining shapes as vectors. Because they’re defined as vectors, they are resolution-independent layers. At render time, Core Animation will create a bitmap that is the appropriate size to match the device’s screen scale. The result is that shape layers will always look crisp when drawn.1

Shape layers can be stroked and filled, and their lines’ properties can be adjusted as well. In true Core Animation fashion, shape layers also have many animatable properties, which allows developers to easily create compelling animations.2 Most importantly, CAShapeLayer is, unsurprisingly, rendered entirely on the GPU, making it very fast.3 With that said, let’s see how to create shape layers.

 

https://www.calayer.com/core-animation/2016/05/22/cashapelayer-in-depth.html 

 

继承与,在创建时需要赋给,并且其形状是矩形的,而 的形状是根据特定的来决定的

 

CAShapeLayer 

使用CAShapeLayer有以下一些优点:

  • 渲染快速。CAShapeLayer使用了硬件加速,绘制同一图形会比用Core Graphics快很多。
  • 高效使用内存。一个CAShapeLayer不需要像普通CALayer一样创建一个寄宿图形,所以无论有多大,都不会占用太多的内存。
  • 不会被图层边界剪裁掉。一个CAShapeLayer可以在边界之外绘制。你的图层路径不会像在使用Core Graphics的普通CALayer一样被剪裁掉(如我们在第二章所见)。
  • 不会出现像素化。当你给CAShapeLayer做3D变换时,它不像一个有寄宿图的普通图层一样变得像素化。

 

https://www.cnblogs.com/jingdizhiwa/p/5535619.html

 

CAShapeLayer-What Shape Layers Are

标签:像素   gpu   draw   depend   size   als   anim   making   nes   

原文地址:https://www.cnblogs.com/feng9exe/p/10343528.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!