joshim5
joshim5

Reputation: 2255

Scaling Animation iPhone

Can anyone describe a way to create an animated scaling affect on the iPhone? I would like an image to start small, and then grow while fading. Motion tweening would also be helpful. Is quartz neccessary for this? I'd prefer to use something as simple as possible.

Thanks SO!

Upvotes: 0

Views: 724

Answers (2)

Ken Pespisa
Ken Pespisa

Reputation: 22266

You can use

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];

myImageView.alpha = 0.0;
myImageView.size = CGSizeMake(myImageView.size.width*2,myImageView.size.height*2);

[UIView commitAnimations];

This does require the CoreAnimations framework to be added to your project.

Upvotes: 1

Jonathan
Jonathan

Reputation: 1602

You can do this all using UIViews/CALayer.

If the values you wish to expand to are predefined it's very easy.

you can use a CABasicAnimation where you set the new CGSize for the view/layer, and the length of the transition, coupled with another where you adjust the opacity of the view/layer. Add these two animations to the view. Motion tweening can be achieved by adjusting the position/frame of the object inside of a animation block.

This this section from the apple documentation on Core Animation for more information, and some basic examples

Upvotes: 0

Related Questions