iOS 12 tabbar 从二级页面返回时,出现跳动解决办法

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) 导致的。
所以最简单的解决方案就是:

在UITabBarController的viewDidLoad方法中加入:

[UITabBar appearance].translucent = NO;

原文地址:https://www.cnblogs.com/FZP5/p/10042998.html