swift中的转场动画
发布时间:2020-12-14 06:30:15 所属栏目:百科 来源:网络整理
导读: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的子类 用
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. } }
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |