ios-使用标签导航模式
来源:互联网 发布:安卓处理json实体类 编辑:程序博客网 时间:2024/06/05 19:48
// 标签导航模式
/*
标签导航模式是非常重要的导航模式。使用标签狼时,有一定的指导原则:标签栏位于屏幕下方,占有49点的屏幕空间,有时可以隐藏起来;为了点击方便,标签栏中的标签不能超过5个,超过5个,则最后一个显示为“更多,点击“更多”标签会出现更多的列表”。
*/
代码实现如下:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; self.window.backgroundColor = [UIColor grayColor]; [self.window makeKeyAndVisible]; UITabBarController *tabBarViewController = [[UITabBarController alloc] init]; self.window.RootViewController = tabBarViewController; [tabBarViewController release]; FirstViewController* first = [[FirstViewController alloc]init]; SecondViewController* second = [[SecondViewController alloc]init]; tabBarViewController.viewControllers = [NSArray arrayWithObjects:first, second, nil]; [first release]; [second release]; // 设置UITabBarItem标题 UITabBar *tabBar = tabBarViewController.tabBar; UITabBarItem *tabBarItem1 = [tabBar.items objectAtIndex:0]; UITabBarItem *tabBarItem2 = [tabBar.items objectAtIndex:1]; tabBarItem1.title = @"第一视图"; tabBarItem2.title = @"第二视图"; /* 注意:这里有多少个视图控制器,就有多少个UITabBarItem,不能超过视图控制器的个数,如果过视图控制器超过5个,最后一个将会显示more */ // 设置UITabBarItem的icon和选中icon [tabBarItem1 setFinishedSelectedImage:[UIImage imageNamed:@"111.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"111.png"]]; [tabBarItem2 setFinishedSelectedImage:[UIImage imageNamed:@"222.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"222.png"]]; // 设置UITabBarItem标题文字选中颜色 UIColor *titleHighlightedColor = [UIColor colorWithRed:153/255.0 green:192/255.0 blue:48/255.0 alpha:1.0]; [[UITabBarItem appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys:titleHighlightedColor, UITextAttributeTextColor, nil] forState:UIControlStateHighlighted]; return YES;}
至此,标签导航介绍已经完毕,程序运行效果图如下:
ios 6效果图:
ios 7效果图:
0 0
- ios-使用标签导航模式
- ios-使用平铺导航模式
- ios-使用树形结构导航模式
- iOS导航模式
- iOS导航模式综述
- ActionBar之使用导航标签
- HTML5 nav导航标签使用
- iOS导航栏使用
- IOS:标签栏与导航栏
- iOS 标签栏和导航栏
- IOS 自定义导航栏和标签栏
- Ios中导航栏和标签栏的结合以及UIButton、UILabel的使用
- ios导航栏的使用
- iOS导航控制器的使用
- IOS使用分组导航标记
- UITabBarController标签导航控制器的使用
- 移动产品设计之ios导航模式
- iOS开发那些事-nib实现标签导航
- Eclipse导入外来工程出错处理
- Python sqlite3库使用
- 基于粒子滤波的目标跟踪基本算法(Matlab)
- 【经典案例】贪吃蛇 AI 的实现 snake AI
- Leetcode 贪心 Longest Consecutive Sequence
- ios-使用标签导航模式
- UML之用例图
- 可伸缩系统的架构经验
- Java学习注意【1】
- UML之类图
- UML之包图
- 安装Android SDK失败了的看过来(东软开源镜像介绍)
- UML之序列图
- 为什么电脑特效这么贵