Hi guys,
Is it possible to animate the bounds of the CALayer on iPhone? How to implement that? Thanks!
Hi guys,
Is it possible to animate the bounds of the 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.
I am trying to do something like the Marvels Comics kind of image scrolling. I think I got my answer for now.
By the way, I only use CALayer to do this. I read somewhere that UIKit can do this too. Which would be a better choice?