您的位置:首页 > 移动开发 > IOS开发

iOS11 自定义tabbar遇到的问题,删除系统自带tabbar按钮

2017-11-13 11:34 288 查看
自定义tabber,就是创建自己的tabbar盖在系统的tabbar上面

        
      //自定义tabbar

    GJWTabBar *customTabBar = [[GJWTabBar
alloc] init];

    customTabBar.frame =
self.tabBar.bounds;

    customTabBar.delegate =
self;

    [self.tabBar
addSubview:customTabBar];

    self.customTabBar = customTabBar;

  //
删除系统自动生成的UITabBarButton

- (void)viewWillAppear:(BOOL)animated

{

    [super viewWillAppear:animated];

    

    // 删除系统自动生成的UITabBarButton

    for (UIView *child
in self.tabBar.subviews) {

        if ([child
isKindOfClass:[UIControl
class]]) {

            [child removeFromSuperview];

        }

    }

}

可是当我运行时候,系统自带的按钮依然像盖在
上面,出现两个tabbar,之前的ios11以前都没有这个问题的。
后来发现在-(void)viewDidAppear:(BOOL)animated里面重新调用删除系统自带tabbar
就可以了。

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐