UITabBarController整理
来源:互联网 发布:淘宝上同款价格差好多 编辑:程序博客网 时间:2024/05/26 12:57
专题名:UITabBarController
UI:UITabBarItem图片尺寸:30*30px。
一、创建TabBae:
1、根页面创建:
UITabBarController如果要作为整个程序的rootViewController,则在application delegate中的 applicationDidFinishLaunching:方法中添加如下代码:(以下代码带导航栏)
HSHomeViewController *hsHome = [[HSHomeViewController alloc]init]; UINavigationController *homeNav = [[UINavigationController alloc]initWithRootViewController:hsHome]; HSOpenInfoViewController *hsOpen = [[HSOpenInfoViewController alloc]init]; UINavigationController *openNav = [[UINavigationController alloc]initWithRootViewController:hsOpen]; HSMyInfoViewController *hsMy = [[HSMyInfoViewController alloc]init]; UINavigationController *myNav = [[UINavigationController alloc]initWithRootViewController:hsMy]; HSMoreViewController *hsMore = [[HSMoreViewController alloc]init]; UINavigationController *moreNav = [[UINavigationController alloc]initWithRootViewController:hsMore]; UITabBarController * tabBar = [[UITabBarController alloc]init]; tabBar.viewControllers =[NSArray arrayWithObjects:homeNav,openNav,myNav,moreNav, nil]; self.window.rootViewController = tabBar;
二、改变每个tab的内容:
1、IOS7.0以上版本:创建方法:
UITabBarItem *item1 = [[UITabBarItem alloc]initWithTitle:@"彩票大厅" image:[UIImage imageNamed:@"tab_home_false.png"] selectedImage:[UIImage imageNamed:@"tab_home_true.png"]];<pre name="code" class="objc">viewController2.tabBarItem = item;IOS7.0以下版本:创建方法:
UITabBarItem *item = [[UITabBarItem alloc] initWithTitle:@"Second" image:nil tag:2];[item setFinishedSelectedImage:[UIImage imageNamed:@"second.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"first.png"]];viewController2.tabBarItem = item;
2、属性badgeValue,该属性可以在其右上角显示一个小的角标,通常用于提示用户有新的消息。
3、改变tabBarItem的文字颜色:
[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor grayColor], UITextAttributeTextColor, nil] forState:UIControlStateNormal]; [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor redColor], UITextAttributeTextColor, nil] forState:UIControlStateHighlighted];
4、改变tabBar的图标颜色:
UITabBar *tabBar = [tabBarCtr tabBar]; [tabBar setTintColor:[UIColor redColor]];
0 0
- UITabBarController整理
- UITabBarController知识整理
- UITabBarController的使用(整理)
- iOS APP开发整理--UITabBarController,UINavigationController
- UITabbarController
- UITabBarController
- UITabBarController
- UITabBarController
- UITabBarController
- UITabBarController
- UITabbarController
- UITabBarController
- UITabBarController
- UITabBarController
- UITabbarController
- UITabBarController
- UITabBarController
- UITabBarController
- 多线程之线程的中止
- android button按键按下和抬起 长按一直发送
- storm学习一 storm基本概念整理
- 黑马程序员:枚举
- 概率 期望
- UITabBarController整理
- [网络流24题] 餐巾计划问题 (最小费用最大流)
- Linux 下 apache 日志分析与状态查看
- LevelListDrawable学习
- 仿百度搜索框,文本框输入值后提示框显示数据(JQuery+Struts2)
- C++ 如何获取文件夹中的文件列表
- Maven配置Spring+Hibernate Shiro权限控制项目
- vs2010 快捷键大全
- NYOJ 26 孪生素数问题