CAShapeLayer slowing down interface rotation

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, eg 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 (eg 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


似乎这个问题已被iOS 4中的Apple修复。

链接地址: http://www.djcxy.com/p/74246.html

上一篇: CABasicAnimation,旋转,主要放缓

下一篇: CAShapeLayer减慢界面旋转