Applying animation while resizing or moving the view

•

Animation can be applied while its frame, bounds, center, transform, alpha… is being changed.  The key is set start and end values between beginAnimations and commitAnimations, so called animation block.


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

// set original position
[view setFrame:CGRectMake(0, 0, 100, 100)];

// move and grow
[view setFrame:CGRectMake(100, 100, 200, 200)];

[UIView commitAnimations];

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.