MobileDev
MobileDev

Reputation: 3795

UIView transition animation

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? enter image description here

Upvotes: 2

Views: 7685

Answers (1)

user1396151
user1396151

Reputation:

Try this :

 -(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];    
    }

Upvotes: 7

Related Questions