博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
七、UITabBarController
阅读量:6587 次
发布时间:2019-06-24

本文共 2443 字,大约阅读时间需要 8 分钟。

/** *  初始化所有的子控制器 */- (void)setupAllChildViewControllers{        UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];    GFBHomeVC *firstViewController = [sb instantiateViewControllerWithIdentifier:@"GFBHomeVC"];    [self setupChildViewController:firstViewController title:@"首页" tabBarTitle:@"首页" imageName:@"icon_home_normal" selectedImageName:@"icon_home_selected"];        GFBTypesVC *secondViewController = [sb instantiateViewControllerWithIdentifier:@"GFBTypesVC"];    [self setupChildViewController:secondViewController title:@"分类" tabBarTitle:@"分类" imageName:@"iocn_classification_normal" selectedImageName:@"iocn_classification_selected"];        GoodsListVC *thirdViewController = [[GoodsListVC alloc] init];    [self setupChildViewController:thirdViewController title:@"购物车" tabBarTitle:@"购物车" imageName:@"icon_shopping-cart_normal" selectedImageName:@"icon_shopping-cart_selected"];        GFBMineVC *fourthViewController = [sb instantiateViewControllerWithIdentifier:@"GFBMineVC"];    [self setupChildViewController:fourthViewController title:@"个人中心" tabBarTitle:@"个人中心" imageName:@"icon_personal-center_normal" selectedImageName:@"icon_personal-center_selected"];}/** *  初始化一个子控制器 * *  @param childVc           需要初始化的子控制器 *  @param title             标题 *  @param imageName         图标 *  @param selectedImageName 选中的图标 */- (void)setupChildViewController:(UIViewController *)childVc title:(NSString *)title tabBarTitle:(NSString *)tabBarTitle imageName:(NSString *)imageName selectedImageName:(NSString *)selectedImageName{    // 1.设置控制器的属性    childVc.navigationItem.title = title;    // 设置图标    childVc.tabBarItem.image = [UIImage imageNamed:imageName];    childVc.tabBarItem.title = tabBarTitle;        // 设置选中的图标    UIImage *selectedImage = [UIImage imageNamed:selectedImageName];        childVc.tabBarItem.selectedImage = [selectedImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];        UIImage *normalImage = [UIImage imageNamed:imageName];    childVc.tabBarItem.image = [normalImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];            UINavigationController *nav;    if([childVc isKindOfClass:[GFBMineVC class]]) {        nav = [[KLTNavigationController alloc]initWithRootViewController:childVc];    }else {        // 2.包装一个导航控制器        nav = [[GFBBaseNaVC alloc] initWithRootViewController:childVc];    }    [self addChildViewController:nav];    }复制代码

转载地址:http://zghno.baihongyu.com/

你可能感兴趣的文章
探测能源、跨洲安全通信……你所想不到的量子技术!
查看>>
bootstrap16-上下文表格布局
查看>>
不规则物体形状匹配综述
查看>>
自动化设计-框架介绍 TestCase
查看>>
CJ看showgirl已经out!VR体验才是王道
查看>>
postgresql 数组类型
查看>>
Vue+Webpack常见问题(持续更新)
查看>>
栈与递归的实现
查看>>
Manually Summarizing EIGRP Routes
查看>>
spring boot 1.5.4 整合webService(十五)
查看>>
modsecurity(尚不完善)
查看>>
在mac os中设置环境变量
查看>>
获取.propertys文件获取文件内容
查看>>
Redis3.0.5配置文件详解
查看>>
Keepalived+Nginx实现高可用
查看>>
Know about Oracle RAC Heartbeat
查看>>
JQuery——实现Ajax应用
查看>>
前端05.js入门之BOM对象与DOM对象。
查看>>
CISCO路由器NTP服务器配置
查看>>
oracle kill所有plsql developer进程
查看>>