swift中的转场动画

来源:互联网 发布:zynga 知乎 编辑:程序博客网 时间:2024/06/05 06:46
class ViewController: UIViewController {

    @IBOutlet weak var layerView: UIView!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    
//        CATransition 是CAAnimation的子类 用于做转场动画,能够为层提供移出和移入屏幕的方法
     
    }

    
    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        
        let transition:CATransition = CATransition()
        
        transition.type = kCATransitionPush
        
        transition.subtype = kCATransitionFromBottom
        
        transition.duration = 8
        
        transition.isRemovedOnCompletion = true
        
        let layerViewLayer = self.layerView.layer
     
        layerViewLayer.add(transition, forKey: "")
        
    
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}


0 0
原创粉丝点击