Transition behavior using transitionFromView and transitionWithView

后端 未结 7 594
既然无缘
既然无缘 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:10

    You need to remove and add the subviews in the animation block. Also, I think that transitionWithView is supposed to take the super view as argument. I think what you need to do to get this right is to use a container view that is the same size as the views you want to flip.

    This is copied from the documentation:

    [UIView transitionWithView:containerView
           duration:0.2
           options:UIViewAnimationOptionTransitionFlipFromLeft
           animations:^{ [fromView removeFromSuperview]; [containerView addSubview:toView]; }
           completion:NULL];
    

提交回复
热议问题