It is clear how to do a zoom in/scaling animation and how to animate an image changing to another. But I need an image to zoom in and midway transform to another. How can it be done?
Asked
Active
Viewed 475 times
1
-
please share your code and explain in detail – Jignesh Mayani May 05 '17 at 11:06
-
@JigneshMayani - There is no associated code. I need an UIImage to get bigger and before the animation ends I need to change the image in it with animation (no abrupt change). – Harikrishnan R May 08 '17 at 07:33
-
You could try to make two image overlap on top of each other and add some kind of transition which change the opacity of one image to make it more transparent over time. – Loïc Faure-Lacroix May 09 '17 at 11:24
2 Answers
1
This code will work for you.
[UIView animateWithDuration:2.0 animations:^{
imgView.transform = CGAffineTransformMakeScale(1.5, 1.5);
}
completion:^(BOOL finished){
[UIView transitionWithView:self.view
duration:2.0f
options:UIViewAnimationOptionTransitionCrossDissolve
animations:^{
[imgView setImage:[UIImage imageNamed:@"default_avatar"]];
imgView.transform = CGAffineTransformMakeScale(2.0, 2.0);
} completion:nil];
}];

Jignesh Mayani
- 6,937
- 1
- 20
- 36
0
Try this code :
[UIView animateWithDuration:2.0 animations:^{
self.imgView.transform = CGAffineTransformMakeScale(1.5, 1.5);
}
completion:^(BOOL finished){
_imgView.image = [UIImage imageNamed:@"3D_search"];
[UIView animateWithDuration:2.0 animations:^{
self.imgView.transform = CGAffineTransformMakeScale(2.0, 2.0);
}];
}];

Arun
- 2,271
- 1
- 14
- 18
-
The image change is abrupt here. I tried putting the change in animation also. But the timing is not fitting. – Harikrishnan R May 08 '17 at 07:37