TabBar Controller 项目动画在 swift 中使用?
TabBar Controller item animation use in swift?
我一直在使用 swift 开发 ios 3 months.I 我只是有点好奇 animations.I 一直在使用应用程序并且这个应用程序有有趣的标签栏项目。这个栏项目每 3 秒改变一次。我如何编码?? First Second Third。感谢一切
有一种更简单的方法可以做到这一点。在标签栏委托中添加以下代码:
class MySubclassedTabBarController: UITabBarController {
override func viewDidLoad() {
super.viewDidLoad()
delegate = self
}
}
extension MySubclassedTabBarController: UITabBarControllerDelegate {
func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool {
guard let fromView = selectedViewController?.view, let toView = viewController.view else {
return false // Make sure you want this as false
}
if fromView != toView {
UIView.transition(from: fromView, to: toView, duration: 0.3, options: [.transitionCrossDissolve], completion: nil)
}
return true
}
}
我一直在使用 swift 开发 ios 3 months.I 我只是有点好奇 animations.I 一直在使用应用程序并且这个应用程序有有趣的标签栏项目。这个栏项目每 3 秒改变一次。我如何编码?? First Second Third。感谢一切
有一种更简单的方法可以做到这一点。在标签栏委托中添加以下代码:
class MySubclassedTabBarController: UITabBarController {
override func viewDidLoad() {
super.viewDidLoad()
delegate = self
}
}
extension MySubclassedTabBarController: UITabBarControllerDelegate {
func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool {
guard let fromView = selectedViewController?.view, let toView = viewController.view else {
return false // Make sure you want this as false
}
if fromView != toView {
UIView.transition(from: fromView, to: toView, duration: 0.3, options: [.transitionCrossDissolve], completion: nil)
}
return true
}
}