How to combine translation scale and animation

I'm trying to make a UIView animation where my image starts in the upper left corner of the screen and expands to its original size and fits in the middle of the screen. So far, I could do it separately, but when I try to combine these animations, it will only do scale animations.

Is there any way to make this work with Scaling and Translation at the same time ?

Here is what I still have:

CGAffineTransform setpointTrans = CGAffineTransformMakeTranslation(-200.0f, -200.0f); CGAffineTransform setpointScale = CGAffineTransformMakeScale(0.0f, 0.0f); _RSEImage.transform = CGAffineTransformConcat(setpointTrans, setpointScale); [UIView beginAnimations:nil context:nil]; [UIView setAnimationDelegate:self]; [UIView setAnimationDuration:5]; [UIView setAnimationCurve:UIViewAnimationCurveEaseOut]; CGAffineTransform scaleTrans = CGAffineTransformMakeScale(1.0f, 1.0f); CGAffineTransform lefttorightTrans = CGAffineTransformMakeTranslation(0.0f,0.0f); _RSEImage.transform = CGAffineTransformConcat(scaleTrans, lefttorightTrans); [UIView commitAnimations]; 

Ok, I realized, here is what I changed:

 _RSEImage.transform = CGAffineTransformMakeScale(0.0f, 0.0f); [UIView beginAnimations:nil context:nil]; [UIView setAnimationDelegate:self]; [UIView setAnimationDuration:5]; [UIView setAnimationCurve:UIViewAnimationCurveEaseOut]; CGAffineTransform scaleTrans = CGAffineTransformMakeScale(1.0f, 1.0f); CGAffineTransform lefttorightTrans = CGAffineTransformMakeTranslation(200.0f,200.0f); _RSEImage.transform = CGAffineTransformConcat(scaleTrans, lefttorightTrans); [UIView commitAnimations]; 
+6
source share
1 answer

You can use this, animation blocks, also (from iOS4):

 [UIView animateWithDuration: 5 delay: 0 options: (UIViewAnimationOptionCurveLinear | UIViewAnimationOptionAllowUserInteraction) animations:^{_RSEImage.center = CGPointMake(300, 300) ; _RSEImage.transform = CGAffineTransformScale(CGAffineTransformIdentity, 2.0, 2.0);} completion:^(BOOL finished) { } ]; 

Relevant white paper here: link

Good tutorial: link

Hope this helps!

+2
source

Source: https://habr.com/ru/post/945636/


All Articles