美文网首页
关于移除系统的tabBar里的子Button控件

关于移除系统的tabBar里的子Button控件

作者: 加盐白咖啡 | 来源:发表于2019-08-12 01:14 被阅读0次

仅记录开发中遇到的问题,网上搜索,记录一下解决办法,如有疑义,请留言!
我在测试的时候用的是iOS12.2系统,在这个方法打印了一下,UITabBarButton还没加载出来,所以移除无效。

- (void)viewWillAppear:(BOOL)animated
  • 在iOS11系统以后需要在下面方法移除
#pragma mark 这个方法移除系统的UITabBarButton
- (void)viewDidAppear:(BOOL)animated {
    for (UIView *view in self.tabBar.subviews) {
        // 如果不是自己的自定义tabBar,就删除系统自动生成的UITabBarButton
        if (![view isKindOfClass:[JMCTabBar class]]) {
            [view removeFromSuperview];
        }
    }
}
  • iOS11以下好像是在这个方法(没用低系统测试)
#pragma mark 在iOS12.2系统,willAppear里打印tabBar的子控件是空的
- (void)viewWillAppear:(BOOL)animated {
    for (UIView *view in self.tabBar.subviews) {
        // 删除系统自动生成的UITabBarButton
        if (![view isKindOfClass:[JMCTabBar class]]) {
            [view removeFromSuperview];
        }
    }
}

相关文章

网友评论

      本文标题:关于移除系统的tabBar里的子Button控件

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