[英]CAShapeLayer with CAShapeLayer sublayer slow
I have a UIScrollView with CAShapeLayer sub layer that renders a simple line. 我有一个带有CAShapeLayer子层的UIScrollView,它呈现一条简单的线。 The CAShapeLayer sublayer has its own sub CAShapeLayer. CAShapeLayer子层有自己的子CAShapeLayer。 This causes scrolling and zooming to be slow. 这会导致滚动和缩放变慢。 The hierarchy is like this: 层次结构如下:
-UIScrollViewLayer -CAShapeLayer -CAShapeLayer -UIScrollViewLayer -CAShapeLayer -CAShapeLayer
If I change this the hierarchy so that it is only one level deep I do not have performance issues: 如果我更改此层次结构,使其只有一个级别,我没有性能问题:
-UIScrollViewLayer -CAShapeLayer -CAShapeLayer -UIScrollViewLayer -CAShapeLayer -CAShapeLayer
What am i doing wrong? 我究竟做错了什么?
Cemel, Cemel,
So my scroll view controller is currently doing this: 所以我的滚动视图控制器目前正在这样做:
[self.uiview.layer addSublayer:myCALayer];
myCaLayer also does this in its init method: myCaLayer也在其init方法中执行此操作:
CAShapeLayer *overlayLayer = [[CAShapeLayer alloc] init];
[self addSublayer:overlayLayer]
I have found this hierarchy to be slow for some reason. 我发现这种层次结构由于某种原因而变慢。 If I instead flatten the hierarchy and do this in my uiscrollview controller instead: 如果我改为压平层次结构并在我的uiscrollview控制器中执行此操作:
[self.uiview.layer addSublayer:myCALayer];
CAShapeLayer *overlayLayer = [[CAShapeLayer alloc] init];
[self.uiview.layer addSublayer:overlayLayer]
Then performance is much better. 然后表现要好得多。 Hope that makes more sense. 希望更有意义。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.