ios12.1 tabBar 中的圖標及文字出現位置偏移動畫

轉自:https://blog.csdn.net/longge_li/article/details/83654333 

昨天更新12.1之後,發現app 首頁push一個界面,返回的時候,tabBar上的圖標和文字出現一個從上往下的神奇動畫,驚呆了😮!
經過測試發現,如果使用系統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;

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章