zoukankan      html  css  js  c++  java
  • 切换view的动画

    代码:

    #import "MainViewController.h"
    
    @interface MainViewController ()
    
    @end
    
    @implementation MainViewController
    
    
    - (void)viewDidLoad
    {
        [super viewDidLoad];
        
        UIView *view1 = [[UIView alloc]initWithFrame:[[UIScreen mainScreen] bounds]];
        view1.backgroundColor = [UIColor blueColor];
        
        UIView *view2 = [[UIView alloc]initWithFrame:[[UIScreen mainScreen] bounds]];
        view2.backgroundColor = [UIColor yellowColor];
    
        [self.view addSubview:view1];
        [self.view addSubview:view2];
    }
    
    -(void) changeView
    {
        NSLog(@"change view");
        CGContextRef context = UIGraphicsGetCurrentContext();
        [UIView beginAnimations:nil context:context];
        [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
        [UIView setAnimationDuration:1.0];
           
        [UIView setAnimationTransition: UIViewAnimationTransitionFlipFromRight forView:self.view cache:YES];
        [self.view exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
        
        [UIView setAnimationDelegate:self];
        [UIView setAnimationDidStopSelector:nil];
        [UIView commitAnimations];
    }
    
    -(void) changeView2
    {
        CATransition *animation = [CATransition animation];
        [animation setDuration:1.25f];
        [animation setTimingFunction:[CAMediaTimingFunction
                                      functionWithName:kCAMediaTimingFunctionEaseIn]];
        [animation setType:kCATransitionReveal];
        [animation setSubtype: kCATransitionFromRight];
        [self.view.layer addAnimation:animation forKey:@"Reveal"];
        
        [self.view exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
       
        [CATransaction commit];
    }
    
    -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
    {
        [self changeView];
    }
    @end
  • 相关阅读:
    将项目中某些常用设置做成配置项
    资产管理平台去除zabbix字样
    navicat远程连接报错
    Excel数据导入MySql数据库
    Ubuntu16.04使用命令行安装jdk1.8
    zabbix4.0配置短信报警
    整洁代码系列(2)
    找回篮球场上的快乐
    努力做人、努力学习、努力让身边的人过得更好 --2016年总结、2017年规划
    整洁代码系列(1)
  • 原文地址:https://www.cnblogs.com/code-style/p/4010616.html
Copyright © 2011-2022 走看看