CAShapeLayer slowing down interface rotation
Posted
by MrMage
on Stack Overflow
See other posts from Stack Overflow
or by MrMage
Published on 2010-01-09T13:43:05Z
Indexed on
2010/05/31
6:02 UTC
Read the original article
Hit count: 402
Hi,
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 CGPath
s 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 UIViewController
s view contains a view with a subclass of CAGradientLayer
as its layerClass
(e.g. a view with a gradient layer as background).
Cheers
MrMage
© Stack Overflow or respective owner