@interface RootViewController (){
    UIView *view1;
    UIView *view2;
    int    flag;
}

@end

@implementation RootViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    flag = 1;
    
    UIButton *button = [[UIButton alloc]initWithFrame:CGRectMake(130, 65, 50, 35)];
    [button setTitle:@"点击" forState:UIControlStateNormal];
    [button setTitleColor:[UIColor greenColor] forState:UIControlStateNormal];
    [button addTarget:self action:@selector(click) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];
    
    view1 = [[UIView alloc]initWithFrame:CGRectMake(0, 100, 320, 480)];
    view1.backgroundColor = [UIColor grayColor];
    
    view2 = [[UIView alloc]initWithFrame:CGRectMake(0, 100, 320, 480)];
    view2.backgroundColor = [UIColor orangeColor];
}

- (void)click{
    
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.6f];
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:NO];
    
    if (flag == 1) {
        
        [self.view addSubview:view1];
        flag = 2;
        
    }else if(flag == 2){
        
        [self.view addSubview:view2];
        flag = 1;
    }
    [UIView commitAnimations];
}

 

相关文章:

  • 2022-12-23
  • 2021-08-09
  • 2021-05-20
  • 2021-09-11
  • 2021-07-10
  • 2021-04-25
  • 2021-11-29
  • 2022-02-06
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-29
  • 2022-12-23
  • 2021-11-29
  • 2022-12-23
  • 2021-07-07
相关资源
相似解决方案