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
  • 相关阅读:
    ​DBEngines 11月数据库排名:PostgreSQL坐稳同期涨幅榜冠军宝座
    深入了解 BTree 和 B+Tree 的区别
    exec详解
    javascript之property's attributes
    极客公园之李彦宏讲话要点
    C++之auto_ptr
    javascript之属性状态控制Method
    ARM寄存器简介
    linux之fcntl
    http之100continue
  • 原文地址:https://www.cnblogs.com/code-style/p/4010616.html
Copyright © 2011-2022 走看看