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
  • 相关阅读:
    jvm字节码简介
    Class类文件结构
    springboot 配置webservice接口
    jdk(1.8)命令行工具(二)
    springboot集成JsonRpc2.0
    jdk命令行工具(一)
    linux安装spark-2.3.0集群
    linux安装scala环境
    [机器学习实践] 针对Breast-Cancer数据集
    mac下 selenium + python 配置和入门
  • 原文地址:https://www.cnblogs.com/code-style/p/4010616.html
Copyright © 2011-2022 走看看