首页 > 代码库 > UITabBarController动态添加TabBarItem
UITabBarController动态添加TabBarItem
NSArray *titles = @[L(@"首页"), L(@"新闻"), L(@"消息"), L(@"我的")]; NSArray *images = @[@"bottom_tabbar_home", @"bottom_tabbar_news", @"bottom_tabbar_message", @"bottom_tabbar_my"]; NSArray *imagesSel = @[@"bottom_tabbar_home_selected", @"bottom_tabbar_news_selected", @"bottom_tabbar_message_selected", @"bottom_tabbar_my_selected"]; NSMutableArray * tabarr = [NSMutableArray new]; [tabarr addObject:[self createChildrenCtrWithtitle:titles[0]]]; [tabarr addObject:[self createChildrenCtrWithtitle:titles[1]]]; [tabarr addObject:[self createChildrenCtrWithtitle:titles[2]]]; [tabarr addObject:[self createChildrenCtrWithtitle:titles[3]]]; self.viewControllers = tabarr; [self.tabBar.items enumerateObjectsUsingBlock:^(UITabBarItem *item, NSUInteger idx, BOOL *stop) { item.title = titles[idx]; UIImage *img = [UIImage imageNamed:images[idx]]; UIImage *selectImg = [UIImage imageNamed:imagesSel[idx]]; item.image = [img imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; item.selectedImage = [selectImg imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; }];
UITabBarController动态添加TabBarItem
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。