2017-05-05 59 views
1

很明显如何进行放大/缩放animation以及如何将图像动画改为another。但我需要一个图像放大和中途转换到另一个。如何做呢?如何放大和转换动画?

+0

请分享您的代码并详细解释 –

+0

@JigneshMayani - 没有关联的代码。我需要一个UIImage变大,在动画结束之前,我需要用动画改变它的图像(没有突然的变化)。 – LordHari

+0

您可以尝试使两个图像重叠在一起,并添加某种类型的转换,这会改变一个图像的不透明度,使其随时间变得更加透明。 –

回答

0

试试这个代码:

[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); 
         }]; 
        }]; 
+0

这里的图像变化很突兀。我试图把变化也放在动画中。但时机并不合适。 – LordHari

1

该代码会为你工作。

[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]; 
         }];