Search code examples
iosanimationcgaffinetransform

multiple animation blocks not working


I'm trying to translate and scale a view in the same block. For some reason the translate code is over riding the scaling and setting it at 100%. Please help.

[UIView animateWithDuration:0.5 
                        delay:0.0 
                        options:UIViewAnimationCurveEaseInOut
                     animations:^{                              
                         fullView.transform = CGAffineTransformMakeTranslation(0.0, 425.0);
                         fullView.transform = CGAffineTransformMakeScale(0.8, 0.8); 
                     } completion:^(BOOL finished) { }];

SOLUTION - Change 2 transform lines into one with CGAffineTransformConcat:

fullView.transform = CGAffineTransformConcat(CGAffineTransformMakeTranslation(0.0, 425.0), CGAffineTransformMakeScale(0.8, 0.8));

Solution

  • transform is a property that you are setting and then re-setting. What you need to do is construct a CGAffineTransform that consists of a combination of the two transforms. CGAffineTransformConcat() should nicely help you with that.