-
tabbar切換時(shí)伦连,頁(yè)面閃爍問(wèn)題
extension CustomerTabBarController: UITabBarControllerDelegate {
func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool {
UIView.setAnimationsEnabled(false)
return true
}
func tabBarController(_ tabBarController: UITabBarController, didSelect viewController: UIViewController) {
UIView.setAnimationsEnabled(true)
}
}
-
特殊場(chǎng)景下造寝,TabBar的item會(huì)左對(duì)齊如下圖所示
image.png
google上查了家妆,也沒(méi)有好的解決方法。設(shè)置
self.viewControllers
的時(shí)候增加了兩個(gè)UINavigationController()
占位item簸呈,并在shouldSelect
代理方法中對(duì)占位的item進(jìn)行判斷榕订,不響應(yīng)跳轉(zhuǎn),如果有更好的解決方法蜕便,歡迎評(píng)論留言
self.viewControllers = [navi1, UINavigationController(), navi2, UINavigationController(), navi3]
extension CustomerTabBarController: UITabBarControllerDelegate {
func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool {
UIView.setAnimationsEnabled(false)
if let nav = viewController as? UINavigationController {
if nav.viewControllers.isEmpty {
return false
}
}
return true
}
func tabBarController(_ tabBarController: UITabBarController, didSelect viewController: UIViewController) {
UIView.setAnimationsEnabled(true)
}
}
-
iPad上tabbar的樣式問(wèn)題
image.png
if UIDevice.current.userInterfaceIdiom == .pad {
if #available(iOS 17.0, *) {
traitOverrides.horizontalSizeClass = .compact
} else {
}
}
在iPad上顯示傳統(tǒng)樣式