iOS 12 tabbar 從二級頁面返回時(shí),出現(xiàn)跳動解決辦法

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;

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容