zoukankan      html  css  js  c++  java
  • 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];
        }];
  • 相关阅读:
    Css的transform和transition
    移动端事件
    回流和重绘
    Swift更新至2.2版本 语言变化
    编程中遇到的 问题 总结
    NSNotificationCenter
    iOS中boolean、Boolean、BOOL、bool的区别
    推送的 代码实战写法
    MKNetworkKit的使用
    MKNetworkKit 的介绍
  • 原文地址:https://www.cnblogs.com/huzhenchao/p/6898914.html
Copyright © 2011-2022 走看看