0

CAShapeLayer slowing the rotation of the interface

 3 years ago
source link: https://www.codesd.com/item/cashapelayer-slowing-the-rotation-of-the-interface.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

CAShapeLayer slowing the rotation of the interface

advertisements

I am trying to move some custom drawing code from a view into a CAShapeLayer, which then get added as a sublayer to the original view's CALayer. This also works well, but when rotating the device, the animation starts to stutter, e.g. you just see the frame in the original orientation and then the final orientation, with at most one frame in between - not smooth at all. Slide-in and slide-out animations of the corresponding UIViewController are a bit jerky, too (but not that much).

All the CAShapeLayer has in its path is one CGPathAddRect, it is set to be opaque, its opacity is 1.0f and the fillColor is set to opaque blue.

When drawing the path directly in the views drawRect method, however, the animation is smooth. So I suppose it has something to do with the CAShapeLayer being animated during the rotation.

Could you tell me how to either get rid of those jerkiness or just hide the CAShapeLayer when animating? Getting back to just draw CGPaths directly is not an option to me because I rely on the ability of CAShapeLayer to animate its path (it is not animated in my tries with rotating the view).

/update: this also happens when the rotating UIViewControllers view contains a view with a subclass of CAGradientLayer as its layerClass (e.g. a view with a gradient layer as background).

Cheers

MrMage


Well there is a hide property, you could hide the CAShapeLayer then do the animation. Then call a method that un-hides the CAShapeLayer so that you don't see it while it is rotating and then it should be smooth


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK