IOS多媒体-CATransection push和reveal

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_21153627/article/details/84142885
//使用CATransection Reveal制作渐显动画
    func test1() {
        let imageVIew = UIImageView(frame: CGRect(x: 0, y: 100, width: 320, height: 211))
        imageVIew.image = UIImage(named: "Pic4")
        self.view.addSubview(imageVIew)
        
        let animation = CATransition()
        animation.duration = 4//动画时长2s
        //是这动画的巴方速度为由慢至快
        animation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseOut)
        //设置动画的类型为渐显动画
        animation.type = kCATransitionReveal
        imageVIew.layer.add(animation, forKey: "Reveal")
    }

////使用CATransection Push制作入场动画
    func test2() {
        let imageView = UIImageView(frame: CGRect(x: 0, y: 100, width: 320, height: 211))
        imageView.image = UIImage(named: "Pic4")
        self.view.addSubview(imageView)
        
        let animation = CATransition();
        animation.duration = 4
        animation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseOut)
        animation.type = kCATransitionPush
        imageView.layer.add(animation, forKey: "Push")
        
    }

猜你喜欢

转载自blog.csdn.net/qq_21153627/article/details/84142885