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];
        }];
  • 相关阅读:
    11.28 正则表达式
    12.28jQuery 的取值赋值
    11.27 上传下载 图片预览
    11.28 验证控件
    12.23,repeater 分页显示
    12.23,搜索标记
    1.基础CRUD
    C#杀进程与之之子进程
    使用procedump捕获未处理异常的dump
    [.net core] 12.环境变量
  • 原文地址:https://www.cnblogs.com/huzhenchao/p/6898914.html
Copyright © 2011-2022 走看看