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

前端 未结 6 519
一整个雨季
一整个雨季 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:45

    **//flipping view continuously**  
    
    
    
     bool a = NO;
    
    
    -(void)viewDidLoad
    {
    
    
    
    // THIS is the canvass holding the two views this view is flipping
     UIView *v=[[UIView alloc]initWithFrame:CGRectMake(40, 40, 150, 150)];
    
       v.backgroundColor=[UIColor clearColor];
    
        [self.view addSubview:v];
    
         [v addSubview:yourfirstview];
         [v addSubview:yoursecondview];
    
    // calling the method
    
    [NSTimer scheduledTimerWithTimeInterval:2.0
                                         target:self
                                       selector:@selector(flip)
                                       userInfo:nil
                                        repeats:YES];
    
    }
    
    
    
    //flipping view randomly
    
    -(void)flip 
    
    {
    
    if (a == NO) 
    {
    
    [UIView transitionFromView:yourfirstview toView:yoursecondview duration:1.0 options:UIViewAnimationOptionTransitionFlipFromLeft completion:NULL];
            a = YES;
        }
    
    else if(a==YES) 
    {
    
    [UIView transitionFromView:yoursecondview toView:yourfirstview duration:1.0 options:UIViewAnimationOptionTransitionFlipFromLeft completion:NULL];
         a = NO;
      }
    
    }
    

提交回复
热议问题