APP push一個界面,返回的時(shí)候,tabBar上的圖標(biāo)和文字出現(xiàn)一個從上往下的神奇動畫
經(jīng)過測試發(fā)現(xiàn),如果使用系統(tǒng)OS12.1 UINavigationController + UITabBarController( UITabBar 磨砂),在popViewControllerAnimated 會遇到tabbar布局錯亂的問題:
-
(void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{
if (self.childViewControllers.count > 0) {
//如果沒這行代碼,是正常顯示的
viewController.hidesBottomBarWhenPushed = YES;
}[super pushViewController:viewController animated:animated];
}
這個問題是 iOS 12.1 Beta 2 引入的問題,只要 UITabBar 是磨砂的,并且 push viewController 時(shí) hidesBottomBarWhenPushed = YES 則手勢返回的時(shí)候就會觸發(fā),出現(xiàn)這個現(xiàn)象的直接原因是 tabBar 內(nèi)的按鈕 UITabBarButton 被設(shè)置了錯誤的 frame,frame.size 變?yōu)?(0, 0) 導(dǎo)致的。
所以最簡單的解決方案就是:
[UITabBar appearance].translucent = NO;