美文网首页
动态显示、影藏其中某个tabBarItem

动态显示、影藏其中某个tabBarItem

作者: KobeBrant | 来源:发表于2019-10-09 11:33 被阅读0次

关键代码

显示

//显示
    TabBarController *tabBarController = (TabBarController *)[UIApplication sharedApplication].delegate.window.rootViewController;
    NSMutableArray *tabbarViewControllers = [NSMutableArray arrayWithArray: [tabBarController viewControllers]];
    ViewController2 * threeVc = [ViewController2 new];
    threeVc.title = @"三";
    threeVc.tabBarItem.image = [[UIImage imageNamed:@""] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    threeVc.tabBarItem.selectedImage = [[UIImage imageNamed:@""] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    // 为子控制器包装导航控制器
    UINavigationController * navigationVc = [[UINavigationController alloc] initWithRootViewController:threeVc];
    [tabbarViewControllers insertObject:navigationVc atIndex:2];
    [tabBarController setViewControllers: tabbarViewControllers];

影藏

//隐藏
    TabBarController *tabBarController = (TabBarController *)[UIApplication sharedApplication].delegate.window.rootViewController;
    NSMutableArray *tabbarViewControllers = [NSMutableArray arrayWithArray: [tabBarController viewControllers]];
    [tabbarViewControllers removeObjectAtIndex:2];
    [tabBarController setViewControllers: tabbarViewControllers];

相关文章

网友评论

      本文标题:动态显示、影藏其中某个tabBarItem

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