Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to scale and rotate during single animateWithDuration call

I am animating a UIView using the following code. This works great but how do I get it to animate scale at the same time too, I would ideally like it to scale down to 0 whilst it spins.

[UIView animateWithDuration:0.4 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut
                 animations:^(void) {
                     recognizer.view.transform = CGAffineTransformMakeRotation(DegreesToRadians(540));
                     recognizer.view.backgroundColor = [[UIColor alloc] initWithRed:220.0/255.0 green:220.0/255.0 blue:220.0/255.0 alpha:1.0];   
                 }];
like image 862
Chris Avatar asked Jan 20 '13 23:01

Chris


1 Answers

Just use the CGAffineTransformConcat method. Try:

[UIView animateWithDuration:0.4 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut
                 animations:^(void) {
                     recognizer.view.transform = CGAffineTransformConcat(CGAffineTransformMakeRotation(DegreesToRadians(540)), CGAffineTransformMakeScale(1.0, 1.0));
                     recognizer.view.backgroundColor = [[UIColor alloc] initWithRed:220.0/255.0 green:220.0/255.0 blue:220.0/255.0 alpha:1.0];   
                 }];

Hope that Helps!

like image 115
msgambel Avatar answered Oct 21 '22 03:10

msgambel