如何为removeFromSuperview设置动画 [英] How to animate removeFromSuperview

查看:235
本文介绍了如何为removeFromSuperview设置动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过以下方式为子视图的外观设置了动画:

I animated the appearance of my subview with:

CATransition *transition = [CATransition animation];
transition.duration = 0.3;
transition.type = kCATransitionReveal;
[webView.layer addAnimation:transition forKey:nil];

[self.view addSubview:webView];

但现在我要删除我的subView。如何添加动画来执行此操作?像其他CATransition一样?什么时候加?在addSubview之前或之后?

But now I want to remove my subView. How can I add animation to do this? Like other CATransition? When to add this? Before or after addSubview?

推荐答案

那么你可以先做动画并在 animationEndListener call removeFromSuperView

Well you could do the animation first and on the animationEndListener call removeFromSuperView

[UIView animateWithDuration:0.5
    delay:1.0
    options: UIViewAnimationOptionCurveEaseOut
    animations:^{
        yourView.alpha = 0;
    }completion:^(BOOL finished){
        [yourView removeFromSuperview];
    }];

这篇关于如何为removeFromSuperview设置动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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