开发者

CALayer animating the Bounds

Is it possible to animate the bounds of t开发者_开发百科he CALayer on iPhone? How to implement that? Thanks!


Yes, it is possible.

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0f];
[[self view] setBounds:CGRectMake(0.0f, 0.0f, 200.0f, 200.0f)];
[UIView commitAnimations];

This will animate a view controller's view from it's current bounds to a bounds of 200 x 200 over 1 second. It won't change the origin--just the size of the bounds rectangle. This is implicit animation by the way. If you want a more complicated animation, look at using CABasicAnimation and animating explicitly.


Are you trying to animate the visible part of an image inside a layer, were the layer itself maintains size and position?

That's what CAScrollLayer is made for. Use a CAScrollLayer in place of your current Layer and add image-rendering layerl as a subLayer to the CAScrollLayer. You can then use the transform property of the sublayer to achieve that effect.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜