![](/img/trans.png)
[英]tabBarController is nil; can't change selectedIndex on viewDidLoad
[英]Animated transition on TabBarController?.selectedIndex change? (Swift)
是否可以快速創建自定義的tabBarController
類,以動畫顯示選項卡之間的編程和交互過渡?
您可以在選項卡選擇中嘗試此過渡動畫
func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool {
guard let fromView = selectedViewController?.view, let toView = viewController.view else {
return false
}
UIView.transition(from: fromView, to: toView, duration: 0.3, options: [.transitionCrossDissolve], completion: nil)
return true }
供參考使用此鏈接
我只是想通了,然后在另一個線程上發布了答案(下面的鏈接)。 它添加了一個方法:
tabBarController.setSelectedWithIndex(1)
用動畫來完成。
我希望這個對你有用!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.