美文网首页iOS开发
iOS tabBar 文字出现位置偏移

iOS tabBar 文字出现位置偏移

作者: 小和大大 | 来源:发表于2018-11-15 17:26 被阅读0次

    昨天更新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;

    ---------------------原文:https://blog.csdn.net/longge_li/article/details/83654333

    我是将这句话放到了自定义的tabbarController的viewdidload方法中,暂时测试无问题了

    相关文章

      网友评论

        本文标题:iOS tabBar 文字出现位置偏移

        本文链接:https://www.haomeiwen.com/subject/uszyfqtx.html