How to flip an individual UIView (without flipping the parent view)

前端 未结 6 509
一整个雨季
一整个雨季 2020-11-27 15:16

This is an iPad project where I have a UIView with several subViews, and I am trying to animate one of this UIViews using [UIView transitionFromView:toView:duration:options:

6条回答
  •  自闭症患者
    2020-11-27 15:43

    this code may helps you:

    put the two views you want to flip inside an unnamed view with the same size and link the IBOutlet UIView *newView,*oldView; to the views and put the new view on top

    bool a = NO;
    
    @implementation ViewController
    
    - (IBAction)flip:(id)sender 
    {
        if (a == NO) {
            [UIView transitionFromView:oldView toView:newView  
                      duration:1.0 
                      options:UIViewAnimationOptionTransitionFlipFromLeft 
                      completion:NULL];
            a = YES; // a = !a;
        }
        else {
            [UIView transitionFromView:newView toView:oldView  
                      duration:1.0 
                      options:UIViewAnimationOptionTransitionFlipFromLeft 
                      completion:NULL];
            a = NO; // a = !a;
        }
    }
    

提交回复
热议问题