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
  • 相关阅读:
    所有时间测试函数
    时间函数应用 time
    50个c/c++源代码网站
    ASN.1详解
    SNMP协议
    SNMP协议详解
    大数据需要建立规则和标准
    常用的三层架构设计
    构建大型网站架构十步骤
    iOS 应用程序内部国际化,不跟随系统语言
  • 原文地址:https://www.cnblogs.com/code-style/p/4010616.html
Copyright © 2011-2022 走看看