Xcode9学习笔记54 - 使用CATransaction Reveal制作动画

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        let rect = CGRect(x: 0, y: 0, width: 499, height: 726)
        let imageView = UIImageView(frame: rect)
        
        let image = UIImage(named: "Pic3")
        imageView.image = image//给图像视图添加要显示的图片
        
        self.view.addSubview(imageView)
        
        let animation = CATransition()
        animation.duration = 2//设置动画时长2秒
        //设置动画的播放速度为由慢至块
        animation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseOut)
        animation.type = kCATransitionReveal//设置动画的类型为渐显动画
        
        imageView.layer.add(animation, forKey: "Reveal")//将动画指定给图像视图的层
    }

  

 

posted on 2017-11-15 07:35  业余极客  阅读(237)  评论(0编辑  收藏  举报

导航