swift中的转场动画

前端之家收集整理的这篇文章主要介绍了swift中的转场动画前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
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.
}


}

原文链接:https://www.f2er.com/swift/322322.html

猜你在找的Swift相关文章