系统UITabbarController
2016-02-18 11:43
411 查看
新建MainTabbarController类
特别鸣谢 詹Q同学
在MainTabbarController.m中 - (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor whiteColor]; //创建viewContronllers [self createViewControllers]; //创建tabBarItems [self createItems]; } #pragma mark 创建viewControllers - (void)createViewControllers { UINavigationController * nc1 = [[UINavigationController alloc] initWithRootViewController:[[viewController1 alloc] init]]; UINavigationController * nc2 = [[UINavigationController alloc] initWithRootViewController:[[viewController2 alloc] init]]; UINavigationController * nc3 = [[UINavigationController alloc] initWithRootViewController:[[viewController3 alloc] init]]; self.viewControllers = @[nc1,nc2,nc3]; } - (void)createItems { NSArray *titleArray = @[@"1", @"2", @"3"]; NSArray *selectImageName = @[@"selected1.png", @"selected2.png", @"selected3.png"]; NSArray *unselectImageName = @[@"normal1.png", @"normal2.png", @"normal3.png"]; for (int i = 0; i < titleArray.count; i++) { //需要对图片进行单独处理 UIImage *selectImage = [UIImage imageNamed:selectImageName[i]]; selectImage = [selectImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; UIImage *unselectImage = [UIImage imageNamed:unselectImageName[i]]; unselectImage = [unselectImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; //以上是防止在bar上显示为阴影而不是图片 UITabBarItem *item = self.tabBar.items[i]; item.selectedImage = selectImage; item.image = unselectImage; item.title = titleArray[i]; } [self.tabBar setBackgroundImage:[UIImage imageNamed:@"img_tabBar_bg_iOS8.png"]]; [[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor orangeColor]} forState:UIControlStateSelected]; [[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor darkGrayColor]} forState:UIControlStateNormal]; }
特别鸣谢 詹Q同学
相关文章推荐
- UITabBarController + UINavigationController 框架相关问题(隐藏TabBar)
- The project was not built since its build path is incomplete
- Android UI开发: 横向ListView(HorizontalListView)及一个简单相册的完整实现 (附源码下载)
- 如何使用Liquibase
- UIPickerView的简单使用
- SystemUI中的访客模式整理
- 监听到UITextField的文本文字改变的3种方法
- LeetCode :232. Implement Queue using Stacks(剑指offer面试题)
- 转:getContextPath、getServletPath、getRequestURI的区别
- 你也来学设计模式 之 Builder模式
- UIViewAnimationOptions
- Usage of forceLayout(), requestLayout() and invalidate()
- android 传统蓝牙Bluetooth联通性
- iOS环信3.0集成 (二)UI文件集成
- UITextField
- 使用UITextField 键盘遮盖输入框
- Java调用XML的方法:DocumentBuilderFactory
- 四、UiDevice API 详细介绍
- 为什么Java 两个Integer 中1000==1000为false而100==100为true?
- UI操作 解决方案