zoukankan      html  css  js  c++  java
  • 使用CATransition实现页面的“从左向右” “从右向左”的动画

    -(void)initView{
        UISwipeGestureRecognizer *left_gesture=[[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(action:)];
        [left_gesture setDirection:UISwipeGestureRecognizerDirectionLeft];
        UISwipeGestureRecognizer *right_gesture=[[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(action:)];
        [right_gesture setDirection:UISwipeGestureRecognizerDirectionRight];
        [self.view addGestureRecognizer:left_gesture];
        [self.view addGestureRecognizer:right_gesture];
    }
    
    -(void)action:(UISwipeGestureRecognizer *)gesture{
        CATransition *animation = [CATransition animation];
        [animation setValue:@"swipe" forKey:@"name"];
        animation.type = kCATransitionReveal;
        if (gesture.direction==UISwipeGestureRecognizerDirectionLeft) {
             animation.subtype = kCATransitionFromRight;
            [self.view setBackgroundColor:[UIColor redColor]];
        }else if(gesture.direction==UISwipeGestureRecognizerDirectionRight){
            animation.subtype = kCATransitionFromLeft;
            [self.view setBackgroundColor:[UIColor blueColor]];
        }
        
           [self.view.layer addAnimation:animation forKey:@"animation"];
    }
  • 相关阅读:
    Javascript注销Window认证登录信息
    Asp.Net文件下载
    Python Beginner's Guide
    StructureMap
    Telerik RadGanttView示例
    SharePoint Server 2010 备份还原和部署
    Bootstrap
    Javascript面向对象基础
    .NET Regular Expressions
    Javascript Arguments Callee Caller
  • 原文地址:https://www.cnblogs.com/niit-soft-518/p/4238253.html
Copyright © 2011-2022 走看看