动画视图缩放 - 弹跳? [英] Animate a view zoom-bouncing in?

查看:94
本文介绍了动画视图缩放 - 弹跳?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有办法为视图设置动画以使其放大并且有点过分而橡皮筋又回到最终尺寸?我不确定如何做这种动画。

Is there a way to animate a view so that it zooms up and kinda goes a bit too far and rubberbands back to the final size? I'm unsure how to do this sort of animation.

推荐答案

当你想要触发这个动画时写下这段代码

write this code when you want to trigger this animation

popUp.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.001, 0.001);

[self.view addSubview:popUp];

[UIView animateWithDuration:0.3/1.5 animations:^{
    popUp.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1.1, 1.1);
} completion:^(BOOL finished) {
    [UIView animateWithDuration:0.3/2 animations:^{
        popUp.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.9, 0.9);
    } completion:^(BOOL finished) {
        [UIView animateWithDuration:0.3/2 animations:^{
            popUp.transform = CGAffineTransformIdentity;                            
        }];
    }];
}];

这是更新的代码(来自fabio.cionini),因为它被接受答案所以更新到最新。

This is updated code (from fabio.cionini) as it is accepted answer so updating to latest.

这篇关于动画视图缩放 - 弹跳?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆