UITabBarController详细说明(简介和设置)
- - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
- {
- self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
- // Override point for customization after application launch.
- self.window.backgroundColor = [UIColor whiteColor];
- #pragma mark - 设置tabBarItem
- #pragma mark 第一个视图ViewController
- HMT_AViewController * tabBarViewA = [[HMT_AViewController alloc] init];
- // 设置A视图下----标签栏标题文字(可參照微信或者QQ体会)
- tabBarViewA.tabBarItem.title = @"微信";
- // 设置A视图下----标签栏图片(由于自己没有图片,在这里随便设置了个名字)
- //tabBarViewA.tabBarItem.image = [UIImage imageNamed:@"1.png"];
- // 设置A视图下----标签栏信息提示(住:badgeValue是NSString类型 例如以下设置了3,就像QQ消息有3条未接受一样,给人一种提醒)
- tabBarViewA.tabBarItem.badgeValue = @"3";
- // ios7弃用了----标签栏选中的时候显示一张图片,没选中的时候显示还有一张图片
- //[tabBarViewA.tabBarItem setFinishedSelectedImage:actionMenu.selectedIcon withFinishedUnselectedImage:actionMenu.icon];
- // ios7的方法(自己没有图片,所以代码里面的图片都是一个随便取的名字,没有有用意义)
- //tabBarViewA.tabBarItem.selectedImage = actionMenu.selectedIcon;
- #pragma mark 第二个视图ViewController
- // 第二个视图ViewController
- HMT_BViewController * tabBarViewB = [[HMT_BViewController alloc] init];
- // 设置B视图下----标签栏
- // 用系统提供的标识(能够算等价于图标和文字)进行设置(參数:UITabBarSystemItem是个枚举值,想要什么形式,就去系统提供的API中找)
- tabBarViewB.tabBarItem = [[UITabBarItem alloc]initWithTabBarSystemItem:UITabBarSystemItemSearch tag:1];
- // 设置B视图下----标签栏信息提示
- tabBarViewB.tabBarItem.badgeValue = @"GO";
- #pragma mark 第三个视图ViewController
- HMT_CViewController * tabBarViewC = [[HMT_CViewController alloc] init];
- tabBarViewC.tabBarItem = [[UITabBarItem alloc]initWithTabBarSystemItem:UITabBarSystemItemDownloads tag:2];
- // 设置B视图下----标签栏信息提示
- tabBarViewC.tabBarItem.badgeValue = @"new";
- #pragma mark 第四个视图ViewController
- HMT_DViewController * tabBarViewD = [[HMT_DViewController alloc] init];
- tabBarViewD.tabBarItem = [[UITabBarItem alloc]initWithTabBarSystemItem:UITabBarSystemItemFavorites tag:3];
- // 设置B视图下----标签栏信息提示
- tabBarViewD.tabBarItem.badgeValue = @"99";
- #pragma mark 第五个视图ViewController
- HMT_EViewController * tabBarViewE = [[HMT_EViewController alloc] init];
- tabBarViewE.tabBarItem = [[UITabBarItem alloc]initWithTabBarSystemItem:UITabBarSystemItemHistory tag:4];
- // 设置B视图下----标签栏信息提示
- tabBarViewE.tabBarItem.badgeValue = @"sky";
- #pragma mark 第六个视图ViewController(系统默认能显示的最大视图个数是5个)
- /* 假设你的viewControllers属性加入了多于五个的items,那tab bar controller将会自己主动插入一个特殊的view controller,
- 称为 More view controller,该 controller 将会负责管理多于的items,这个More view controller提供一个自己定义的界面,
- 用table的方式呈现多余的view controller。而且view controller的数量是不限制的*/
- HMT_FViewController * tabBarViewF = [[HMT_FViewController alloc] init];
- tabBarViewF.tabBarItem = [[UITabBarItem alloc]initWithTabBarSystemItem:UITabBarSystemItemContacts tag:5];
- // 设置F视图下----标签栏信息提示
- tabBarViewF.tabBarItem.badgeValue = @"AG";
- #pragma mark - 设置TabBarController
- // 创建TabBarController
- UITabBarController * tabBarController = [[UITabBarController alloc]init];
- // TabBarController默认是放在最底部的,假设你想调整位置,能够进行以下2部操作(44是iPhone中TabBarController和UINavigationController标准高度)
- //CGRect frame = CGRectMake(0, 20, 320, 44);
- //tabBarController.tabBar.frame = frame;
- // 每个tab都必须有一个content view controller------->viewControllers属性,用来存入一个应用的TabBarController有多少个界面切换
- tabBarController.viewControllers = [NSArray arrayWithObjects:tabBarViewA,tabBarViewB,tabBarViewC,tabBarViewD,tabBarViewE,tabBarViewF, nil nil];
- // 设置着色
- tabBarController.tabBar.tintColor = [UIColor greenColor];
- // 设置选中图片时候
- tabBarController.tabBar.selectedImageTintColor = [UIColor brownColor];
- // 设置背景图片(自己没有图片,不进行设置)
- //tabBarController.tabBar.backgroundImage = [UIImage imageNamed:@"@@@@@"];
- // 设置程序启动时默认的ViewController视图(设置为3,一共5个ViewController,进来时候显示的视图就是第4个-tabBarViewD,下标从0開始)
- tabBarController.selectedIndex = 3;
- self.window.rootViewController = tabBarController;
- [self.window makeKeyAndVisible];
- return YES;
- }
@最后效果例如以下图:
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvenVveW91MTMxNA==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="">
版权声明:本文博主原创文章,博客,未经同意不得转载。
UITabBarController详细说明(简介和设置)的更多相关文章
- UITabBarController 、TabBar背景颜色设置,UITabBarItem的文字样式(颜色和大小)UITabBarItem的位置调整
改变UITabBarController的颜色 UIView*mView=[[UIView alloc]initWithFrame:CGRectMake(0,0,320,48)];//这是部分tabb ...
- Keepalived详细介绍简介
1.1.Keepalived简介 Keepalived是Linux下一个轻量级别的高可用解决方案.高可用(High Avalilability,HA),其实两种不同的含义:广义来讲,是指整个系统的高可 ...
- 详细:idea如何设置类头注释和方法注释
IntelliJ IDEA 类注释和自定义方法注释 来源:https://my.oschina.net/baishi/blog/617478#navbar-header intellj idea的 ...
- CentOS6.6图文详细安装教程(有些设置大部分教程没出现过,附带网络设置等)
作者:Sungeek 出处:http://www.cnblogs.com/Sungeek/ 欢迎转载,也请保留这段声明.谢谢! Centos6.6 下载地址:thunder://QUFodHRwOi8 ...
- 【开发技术】Eclipse插件Call Hierarchy简介及设置
Call Hierarchy 主要功能是 显示一个方法的调用层次(被哪些方法调,调了哪些方法) 在MyEclipse里Help - Software updates - Find and instal ...
- linux设置iptables防火墙的详细步骤(centos防火墙设置方法)
CentOS系统也是基于linux中的它的防火墙其实就是iptables了,下面我来介绍在CentOS防火墙iptables的配置教程,希望此教程对各位朋友会有所帮助. iptables是与Lin ...
- 虚拟机VMWare安装苹果系统MacOS详细教程(联网设置,全屏插件、文件互传)
运行环境: VMware® Workstation 12 Pro(自行安装,或者用这个) 推荐(下面以10.11.6版本做的教程,但是安装时推荐使用此版本安装然后升级到10.11.6):MacOS X ...
- MySQL - binlog日志简介及设置
基本概念 binlog是Mysql sever层维护的一种二进制日志,与innodb引擎中的redo/undo log是完全不同的日志:其主要是用来记录对mysql数据更新或潜在发生更新的SQL语句, ...
- thinkphp路由简介和设置使用
use think\Route; //静态路由 Route::rule('/', 'index/index/index'); Route::rule('test', 'index/index/test ...
随机推荐
- STM32 + RT Thread OS 学习笔记[四]
1. 补注 a) 硬件,打通通讯通道 若学习者购买了学习板,通常可以在学习板提供的示例代码中找到LCD的相关驱动代码,基本上,这里的驱动的所有代码都可以从里面找到. 从上面的示意图可见,M ...
- HttpGet协议与正则表达
使用HttpGet协议与正则表达实现桌面版的糗事百科 写在前面 最近在重温asp.net,找了一本相关的书籍.本书在第一章就讲了,在不使用浏览器的情况下生成一个web请求,获取服务器返回的内容.于 ...
- Bean-Query 一个把对象转换为Map的Java工具库
刚开源了一个经过完整測试的Java工具类. 地址例如以下: https://github.com/Jimmy-Shi/bean-query 使用说明例如以下: Bean-query Click Her ...
- 初始化openwrt的rootpassword
更改openwrt源代码 shadow 文件 package/base-files/files/etc/shadow shadow 文件參考http://blog.csdn.net/u01164188 ...
- Nginx 负载均衡-加权轮询策略剖析
本文介绍的是客户端请求在多个后端服务器之间的均衡,注意与客户端请求在多个nginx进程之间的均衡相区别(Nginx根据每个工作进程的当前压力调整它们获取监听套接口的几率,那些当前比较空闲的工作进程有更 ...
- 黑马程序猿————OC在Foundation框架结构和字符串
------<a href="http://www.itheima.com" target="blank">Java火车.Android火车.iOS ...
- 第27本:《学得少却考得好Learn More Study Less》
第27本:<学得少却考得好Learn More Study Less> <学得少却考得好Learn More Study Less>这本书最早是从褪墨网站上看到的,crownc ...
- windows server 搭建radius服务器
使用ISA 2004搭建PPTP/L2TP 服务器后,VPN账号是在radius服务器上的,使用window server 2003搭建radius服务器,需要添加组件->internet验证服 ...
- 用链表实现栈----《数据结构与算法分析----C语言描述》
一.头文件: #ifndef _STACK_LINK_H_ #define _STACK_LINK_H_ struct stack_record; typedef struct stack_recor ...
- HDU 2544 最短路 SPFA 邻接表 模板
Problem Description 在每年的校赛里,全部进入决赛的同学都会获得一件非常美丽的t-shirt.可是每当我们的工作人员把上百件的衣服从商店运回到赛场的时候,却是非常累的!所以如今他们想 ...
