gpt4 book ai didi

ios - 快速更改 View 时的动画

转载 作者:可可西里 更新时间:2023-11-01 02:14:43 25 4
gpt4 key购买 nike

我是 swift 的新手。我想在将 View 从一个 View Controller 更改为另一个 View Controller 时制作动画。我正在使用 prepareForSegue: 方法点击按钮,我已经搜索了很多但是没有找到任何解决方案有人对此有解决方案吗?

最佳答案

// call following code in the method where you want to add animation effect.

func buttonClicked(sender: UIButton){

let transition = CATransition()
transition.duration = 0.5
transition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
transition.type = kCATransitionPush
transition.subtype = kCATransitionFromRight
self.navigationController?.view.layer.addAnimation(transition, forKey: nil)
self.navigationController?.pushViewController(vc!, animated: true)

}

// you can vary the duration of transition according to your convenience

// here transition.type are types of animation which you want to add on view. now we are pushing view so used push type. if want, you can google it for more types.

// subtype will decide the direction on animation.

关于ios - 快速更改 View 时的动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39467922/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com