Reputation: 28892
I have a UIView that I'm trying to animate.
[UIView beginAnimations:@"scaleAnimation" context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.5];
CGRect f = self.frame;
f.size.width = f.size.width * 2;
f.size.height = f.size.height * 2;
self.frame = f;
[UIView commitAnimations];
The animation works fine, but is there anyway I can make the animation scale along the center?
Right now, it looks like the point is on the top left corner.
Using CGAffineTransform scale = CGAffineTransformMakeScale(2.0, 2.0); does the animation along the center, but doing a touch event, the points seems to get all messed up when I'm trying to detect transparent area of the UIView.
Thank you,
Tee
Upvotes: 0
Views: 839
Reputation: 56625
It's simple. Animate the bounds
instead. As the documentation says:
Changing the bounds size grows or shrinks the view relative to its center point.
So your code would be like this
[UIView beginAnimations:@"scaleAnimation" context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:1.5];
CGRect f = myView.bounds;
f.size.width = f.size.width * 2;
f.size.height = f.size.height * 2;
myView.bounds = f;
[UIView commitAnimations];
Upvotes: 2