Transition behavior using transitionFromView and transitionWithView

后端 未结 7 579
既然无缘
既然无缘 2020-12-05 07:27

I am attempting to create a transition between two subviews (view1 and view2). When a button is pressed I want view1 (front) to flip and show view2 (back). I have tried both

7条回答
  •  独厮守ぢ
    2020-12-05 08:04

    I have run into this exact same problem, and I agree with the earlier answer. It seems you must have a container view for animating a transition from one subview to another subview.

    I'm using the transitionFromView approach. To have a background behind the animation, you will also need a superview with the background for the container view.

    My code looks like:

        [UIView transitionFromView:view1
                            toView:view2
                          duration:0.5
                           options:UIViewAnimationOptionTransitionFlipFromRight |
                                   UIViewAnimationOptionAllowUserInteraction    |
                                   UIViewAnimationOptionBeginFromCurrentState
                        completion:nil];
    

提交回复
热议问题