【问题标题】:How to do zoom in and transform animation?如何放大和变换动画?
【发布时间】:2017-10-03 19:13:55
【问题描述】:

很清楚如何放大/缩放animation 以及如何将图像动画更改为another。但我需要一张图片来放大并中途转换为另一张图片。怎么办?

【问题讨论】:

  • 请分享您的代码并详细解释
  • @JigneshMayani - 没有关联的代码。我需要一个 UIImage 来变大,在动画结束之前我需要用动画改变其中的图像(没有突然变化)。
  • 您可以尝试让两个图像相互重叠,并添加某种过渡来改变一个图像的不透明度,使其随着时间的推移变得更加透明。

标签: ios objective-c iphone uiimageview core-animation


【解决方案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];
                        }];

【讨论】:

    【解决方案2】:

    试试这个代码:

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

    【讨论】:

    • 这里的图像变化很突然。我也尝试在动画中进行更改。但时机不对。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-04-20
    • 1970-01-01
    • 1970-01-01
    • 2011-07-07
    • 2013-06-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多