UITabBarController的一些基础设置
利用代码添加UITabBarController
- - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
- ViewController *vc1 = [[ViewController alloc] init];
- UserGuideViewController *vc2 = [[UserGuideViewController alloc] init];
- UITabBarController *tabBarController = [[UITabBarController alloc] init];
- tabBarController.viewControllers = [[NSArray alloc] initWithObjects:vc1, vc2, nil];
- for(int i=; i<tabBarController.tabBar.items.count; i++) {
- UITabBarItem *item = [tabBarController.tabBar.items objectAtIndex:i];
- item.title = [NSString stringWithFormat:@"子栏目%d",i];
- NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor grayColor],UITextAttributeTextColor, nil];
- [item setTitleTextAttributes:dict forState:UIControlStateNormal];
- NSDictionary *dict2 = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor redColor],
- UITextAttributeTextColor,nil];
- [item setTitleTextAttributes:dict2 forState:UIControlStateSelected];
- }
- self.window.rootViewController = tabBarController;
- [self.window makeKeyAndVisible];
- return YES;
- }
改变TabBar的背景色
方法一:
- UIView *bgView = [[UIView alloc] initWithFrame:self.tabBar.bounds];
- bgView.backgroundColor = [UIColor redColor];
- [self.tabBar insertSubview:bgView atIndex:];
方法二:
- CGRect rect = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);
- UIGraphicsBeginImageContext(rect.size);
- CGContextRef context = UIGraphicsGetCurrentContext();
- CGContextSetFillColorWithColor(context, [[UIColor redColor] CGColor]);
- CGContextFillRect(context, rect);
- UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
- UIGraphicsEndImageContext();
- self.tabBar.backgroundImage = image;
改变TabBarItem的(选择/未选择)背景图片
方法一,改变全局:
- UIImage *bgImage = [UIImage imageNamed:@"Image1"];
- [[UITabBar appearance] setBackgroundImage:[bgImage resizableImageWithCapInsets:UIEdgeInsetsZero]];
- [[UITabBar appearance] setSelectionIndicatorImage:[UIImage imageNamed:@"Image2"]];
方法二,改变特定:
- [self.tabBar setBackgroundImage:[UIImage imageNamed:@"GuideImage1"]];
- [self.tabBar setSelectionIndicatorImage:[UIImage imageNamed:@"GuideImage2"]];
改变TabBarItem的选择与未选择图标
- - (void)viewDidLoad {
- [super viewDidLoad];
- UIImage *carIcon = [UIImage imageNamed:@"CarIcon"];
- UIImage *grayCarIcon = [UIImage imageNamed:@"GrayCarIcon"];
- ViewController *vc1 = [[ViewController alloc] init];
- UITabBarItem *item1 = [[UITabBarItem alloc] initWithTitle:@"栏目A" image:carIcon tag:];
- item1.selectedImage = grayCarIcon;
- vc1.tabBarItem = item1;
- UserGuideViewController *vc2 = [[UserGuideViewController alloc] init];
- UITabBarItem *item2 = [[UITabBarItem alloc] initWithTitle:@"栏目B" image:carIcon tag:];
- item2.selectedImage = grayCarIcon;
- vc2.tabBarItem = item2;
- self.viewControllers = [[NSArray alloc] initWithObjects:vc1, vc2, nil];
- [self setSelectedViewController:vc2];
- }
改变TabBarItem的文本颜色
- UITabBarItem *item = self.tabBar.items[];
- NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor grayColor],UITextAttributeTextColor, nil];
- [item setTitleTextAttributes:dict forState:UIControlStateNormal];
- NSDictionary *dict2 = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor redColor],
- UITextAttributeTextColor,nil];
- [item setTitleTextAttributes:dict2 forState:UIControlStateSelected];
UITabBarController的一些基础设置的更多相关文章
- linux基础-第十四单元 Linux网络原理及基础设置
第十四单元 Linux网络原理及基础设置 三种网卡模式图 使用ifconfig命令来维护网络 ifconfig命令的功能 ifconfig命令的用法举例 使用ifup和ifdown命令启动和停止网卡 ...
- hibernate----hibernate的基础设置
本次学习的内容是hibernate的基础设置 具体内容为: 一.准备工作 1.新建java工程 2.自动引入相关库(自动生成SessionFactory) 3.将数据库驱动拿进来 4.添加hibern ...
- Linux网络服务01——Linux网络基础设置
Linux网络服务01--Linux网络基础设置 一.查看及测试网络 1.使用ifconfig命令查看网络接口 (1)查看活动的网络接口 ifconfig命令 [root@crushlinux ~]# ...
- iptables 生产环境下基础设置
iptables 生产环境下基础设置 生成环境需求:防火墙需要让内网的Ip全部通过,外网IP添加到白名单,其他一切拒绝.安装在linux系统中安装yum install iptables-servic ...
- IntelliJ IDEA 基础设置
原文地址:IntelliJ IDEA 基础设置 博客地址:http://www.extlight.com 一.前言 IDEA 全称 IntelliJ IDEA,是java语言开发的集成环境,Intel ...
- 关于responseHeader的一些基础设置
1.关于响应头的一些基础设置 //设置相应头 response.addHeader("name","zhangsan"); response.addIntHea ...
- linux网络基础设置 以及 软件安装
ifconfig #查看所有已激活的网卡信息 临时配置 #yum install net-tools -y 默认ifconfig是没有安装的,可能需要安装 ifconfig eth0 #查看单独一块网 ...
- 项目一:项目第二天 Jquery ztree使用展示菜单数据 2、 基础设置需求分析 3、 搭建项目框架环境--ssh(复习) 4、 SpringData-JPA持久层入门案例(重点) 5、 Easyui menubutton菜单按钮使用 6、 Easyui messager消息框使用
1. Jquery ztree使用展示菜单数据 2. 基础设置需求分析 3. 搭建项目框架环境--ssh(复习) 4. SpringData-JPA持久层入门案例(重点) 5. Easyui menu ...
- 通达OA 小飞鱼工作流在线培训教程(七)工作流应用的意义及基础设置(图文)
这个课程计划已经有一段时间了,经过这段时间结合实际网络教学又进行了一些总结,这里将陆续为大家呈现相关的工作流设计开发课程. 同一时候线上的视频教学课程也将立即上线,欢迎朋友们的关注. 首先介绍一些工作 ...
随机推荐
- CodeFirst写界面——自己写客户端UI库
何谓CBS程序 CBS程序就是Client+Browser+Service的程序 纯CS程序写界面,有各种难处,那么我就在Client端引入Browser,让Browser渲染基于HTML的UI界面 ...
- Cmd命令
write----------写字板 mspaint--------画图板 mobsync--------同步命令 eudcedit-------造字程序 dvdplay--------DVD播放器 ...
- 汇编int21h,DOS调用(转)
表:DOS系统功能调INT 21H AH 功能 调用参数 返回参数 00 程序终止(同INT 20H) CS=程序段前缀 01 键盘输入并回显 AL=输入字符 02 显示输出 DL=输出字符 03 异 ...
- C语言实现二叉树
二叉树的重要性就不用多说啦: 我以前也学习过,但是一直没有总结: 网上找到的例子,要么是理论一大堆,然后是伪代码实现: 要么是复杂的代码,没有什么解释: 最终,还是靠FQ找到一些好的文章,参考地址我会 ...
- Kafka重复消费和丢失数据研究
Kafka重复消费原因 底层根本原因:已经消费了数据,但是offset没提交. 原因1:强行kill线程,导致消费后的数据,offset没有提交. 原因2:设置offset为自动提交,关闭kafka时 ...
- iOS UICollectionView的实现
ios的UICollectionView并不能在iOS6之前的版本中使用,为了兼容之前的版本需要自定义UICollectionView.写完之后发现人家已经有开源了,下过来看了看发现我是用UIScro ...
- nmap端口状态解析
nmap端口状态解析 状态 说明 open 应用程序在该端口接收 TCP 连接或者 UDP 报文 closed 关闭的端口对于nmap也是可访问的, 它接收nmap探测报文并作出响应.但没有应用程序在 ...
- Java开源框架推荐(全)
Build Tool Tools which handle the buildcycle of an application. Apache Maven - Declarative build and ...
- IIS7显示ASP的详细错误信息到浏览器
服务端环境:Windows2008 + IIS7 客户端浏览器设置:取消“显示友好的HTTP错误信息” IIS7设置(GUI): 1. 网站->ASP->调试属性->将错误发送到浏览 ...
- aehyok.com的成长之路一——开篇
前言 不得不说最近三个月都没更新博客了,除了6月初的一篇博客外,今天的这一篇算是这三个月里发表的第二篇博客了.不过本人几乎每天都在博客园里刷来刷去,看大家发表的博文,从中汲取营养.确实博客园也可以 ...