开发者

How to replace the custom animation for a CALayer appearing

I have a CALayer that I w开发者_Python百科ant to change the custom animation for it appearing on screen. I have created a delegate so that I can catch the method:

- (id < CAAction >)actionForLayer:(CALayer *)layer forKey:(NSString *)key

And I check for the key to be equal to kCAOnOrderIn, however, the layer hasn't been told what it's bounds will be yet (it currently reports (0, 0, 0, 0) for the bounds). So then I tried checking for the key to be equal to "bounds" but I still get reported the same rect (0, 0, 0, 0).

The animation I want to do is instead of the layer gradually "unfading" onto the screen via opacity, I want it to grow onto the screen from small and in the middle to it's full bounds. But to do that I need to know what it's full bounds will be. Is there anyway to know that so that I can replace the custom animation, or am I just simply approaching this the wrong way?

Thanks


I know this is 3 months old but I was looking for an answer for a similar problem and notice that this doesn't have an answer (an I'd like some rep ;)

I'm overwriting the actionForLayer:forKey: on a UIView (iPhone SDK) that is automatically set as the delegate to it's backing CALayer in order to inject a different action for anchorPoint. I notice I can get access to the old value via the presentationLayer of the CALayer and the new value is in the modelLayer. But what I think is happening in your case is that the system is calling for the onOrderIn action (perhaps at the time that the layer is added to the view hierarchy) before you have told the layer it's bounds. In fact this is normal.

You should be waiting for the "bounds" in addition to the "onOrderIn" key.

Are you waiting for other keys? "onOrderOut" or "hidden"?

Cheers, Corin

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜