zoukankan      html  css  js  c++  java
  • Swift

    CATransition动画主要在过渡时使用,比如两个页面层级改变的时候添加一个转场效果。CATransition分为两类,一类是公开的动画效果,一类是非公开的动画效果。

    1,公开动画效果:
    kCATransitionFade:翻页
    kCATransitionMoveIn:弹出
    kCATransitionPush:推出
    kCATransitionReveal:移除

    2,非公开动画效果:
    "cube":立方体
    "suckEffect":吸收
    "oglFlip":翻转
    "rippleEffect":波纹
    "pageCurl":卷页
    "cameraIrisHollowOpen":镜头开
    "cameraIrisHollowClose":镜头关

    3,动画方向类型:
    kCATransitionFromRight:从右侧开始实现过渡动画
    kCATransitionFromLeft:从左侧开始实现过渡动画
    kCATransitionFromTop:从顶部开始实现过渡动画
    kCATransitionFromBottom:从底部开始实现过渡动画


    4,下面通过一个样例演示:
    页面上添加两个分别是红色,蓝色的UIView。当点击屏幕的时候,这两个UIView层级切换,同时会有从左向右推出的效果。
     
                  
              

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    import UIKit
     
    class ViewController: UIViewController {
         
        override func viewDidLoad() {
            super.viewDidLoad()
             
            var redView:UIView = UIView(frame: CGRectMake(20,20,280,400))
            redView.backgroundColor = UIColor.redColor()
            self.view.insertSubview(redView, atIndex: 0)
             
            var blueView:UIView = UIView(frame: CGRectMake(20,20,280,400))
            blueView.backgroundColor = UIColor.blueColor()
            self.view.insertSubview(blueView, atIndex: 1)
        }
         
        //点击切换两个红蓝视图
        override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
            var transition = CATransition()
            transition.duration = 3.0
            transition.type = kCATransitionPush //推送类型
            transition.subtype = kCATransitionFromLeft //从左侧
            self.view.exchangeSubviewAtIndex(1, withSubviewAtIndex: 0)
            self.view.layer.addAnimation(transition, forKey: nil)
        }
         
        override func didReceiveMemoryWarning() {
            super.didReceiveMemoryWarning()
        }
    }
  • 相关阅读:
    Windows:Oracle 11g 备份脚本
    PLSQL操作Oracle创建用户和表
    Windows:添加、删除和修改静态路由
    Zabbix3.x 监控磁盘IO与自定义模板
    重置密码解决MySQL for Linux错误 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
    Nginx日志格式log_format详解
    春的请柬
    Action Service Dao三层的功能划分
    关于正则表达式的排除
    jsp中对象的访问
  • 原文地址:https://www.cnblogs.com/Free-Thinker/p/4843421.html
Copyright © 2011-2022 走看看