Xcode9学习笔记54

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        let rect = CGRect(x: 0, y: 0,  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")//将动画指定给图像视图的层
    }

  

原文地址:https://www.cnblogs.com/LisenH/p/7837166.html