简体   繁体   English

UIImageView缩放/淡化动画?

[英]UIImageView Zoom/Fade animation?

I want to make a little zoom/fade animation for when the UIImageView shows up in my view, I already have the code for the fade effect: 我希望在我的视图中显示UIImageView时制作一个小的缩放/淡入淡出动画,我已经有了淡入淡出效果的代码:

    banner.alpha = 0.0;
    [UIView animateWithDuration:2.0 animations:^{
        banner.alpha = 1.0;
    }];

Now I want to know if there is another easy way to combine the fade effect with a little zoom effect, like the image becoming larger and filling up the frame as it fades in? 现在我想知道是否还有另一种简单的方法可以将淡入淡出效果与一点变焦效果结合起来,比如图像变大并在渐弱时填满画面? Any ideas? 有任何想法吗? Thanks! 谢谢!

you can use CG_EXTERN CGAffineTransform CGAffineTransformMakeScale(CGFloat sx, CGFloat sy) to do the zoom effect 你可以使用CG_EXTERN CGAffineTransform CGAffineTransformMakeScale(CGFloat sx, CGFloat sy)来做缩放效果

such as

banner.alpha = 0.0;

[UIView animateWithDuration:2.0 animations:^{
    banner.alpha = 1.0;
    banner.transform =CGAffineTransformMakeScale(1.3,1.3);
}];

You can also use the frame 您也可以使用框架

banner.alpha = 0;

[UIView animateWithDuration:2.0f animations:^(void){
   banner.alpha = 1.0f;
   [banner setFrame:CGRectMake(0, 0, 1024, 748)];
}];

// With Completion
[UIView animateWithDuration:0.1f animations:^(void){
   banner.alpha = 1.0f;
   [banner setFrame:CGRectMake(0, 0, 1024, 748)];
}completion:^(BOOL finished) {

}];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM