UIView过渡动画 [英] UIView transition animation

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

问题描述

ViewB ViewC ViewA 的子视图。假设 ViewB 当前位于 ViewC 的顶部。我想将 ViewC 放在顶部,并翻转动画,如图所示。我使用 UIView 类方法(void)transitionFromView:(UIView *)fromView toView:(UIView *)toView duration:(NSTimeInterval)duration选项: (UIViewAnimationOptions)选项完成:(void(^)(BOOL已完成))完成。但是, ViewA viewB 一起翻转,这不是期望的行为。所需的行为仅用于 ViewB 翻转,并且 ViewC 现在位于顶部。任何想法如何实现所需的行为?

ViewB and ViewC are subviews of ViewA. Say ViewB is currently on top of ViewC. I would like to bring ViewC on top with flipping animation as shown in the diagram. I use the UIView class method (void)transitionFromView:(UIView *)fromView toView:(UIView *)toView duration:(NSTimeInterval)duration options:(UIViewAnimationOptions)options completion:(void (^)(BOOL finished))completion. However, the ViewA gets flipped along with viewB which is not the desired behavior. The desired behavior is only for ViewB to flip over and ViewC is now on top. Any idea how to achieve the desired behavior?

推荐答案

尝试一下:

 -(void)FilpAnimation
    {
        viewObjB.alpha=1.0;
        viewObjB.hidden=NO;
        [UIView transitionWithView:viewObjB
                          duration:1.5
                           options:UIViewAnimationOptionTransitionFlipFromRight
                        animations:^{
                            viewObjB.hidden=YES;
                            viewObjB.alpha=0.0;
                        } completion:nil];

        viewObjC.alpha=0.0;
        viewObjC.hidden=YES;
        [UIView transitionWithView:viewObjC
                          duration:1.5
                           options:UIViewAnimationOptionTransitionFlipFromLeft
                        animations:^{
                            viewObjC.hidden=NO;
                            viewObjC.alpha=1.0;
                        } completion:nil];    
    }

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

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