@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