iOS12.1之后,發現app 首頁push一個界面,返回的時候,tabBar上的圖標和文字出現一個從上往下的神奇BUG.
經過測試發現,如果使用系統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 時 hidesBottomBarWhenPushed = YES 則手勢返回的時候就會觸發,出現這個現象的直接原因是 tabBar 內的按鈕 UITabBarButton 被設置了錯誤的 frame,frame.size 變為 (0, 0) 導致的。
所以最簡單的解決方案就是:
[UITabBar appearance].translucent = NO;