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 小飞鱼工作流在线培训教程(七)工作流应用的意义及基础设置(图文)
这个课程计划已经有一段时间了,经过这段时间结合实际网络教学又进行了一些总结,这里将陆续为大家呈现相关的工作流设计开发课程. 同一时候线上的视频教学课程也将立即上线,欢迎朋友们的关注. 首先介绍一些工作 ...
随机推荐
- 深入理解java虚拟机【Java虚拟机类生命周期】
C/C++等纯编译语言从源码到最终执行一般要经历:编译.连接和运行三个阶段,连接是在编译期间完成,而java在编译期间仅仅是将源码编译为Java虚拟机可以识别的字节码Class类文件,Java虚拟机对 ...
- 微软BI 系列随笔列表 (SSIS, SSRS, SSAS, MDX, SQL Server)
[公告]本博客于2015年10月起不再更新 新博客文章主要发表在商业智能BI社区: http://www.flybi.net/blog/biwork 博客地图自动分类 文章目录方便更好的导航,阅读文章 ...
- JsRender for object 语法说明
JsRender 作为一款JavaScript模版引擎,必不可少的会有循环功能,也就是for,但由于JsRender过于灵活,for竟然可以接受object作为循环对象. {{for Array}}和 ...
- JAVA通过XPath解析XML性能比较(原创)
(转载请标明原文地址) 最近在做一个小项目,使用到XML文件解析技术,通过对该技术的了解和使用,总结了以下内容. 1 XML文件解析的4种方法 通常解析XML文件有四种经典的方法.基本的解析方式有两种 ...
- 你应该知道的RPC原理
你应该知道的RPC原理 在学校期间大家都写过不少程序,比如写个hello world服务类,然后本地调用下,如下所示.这些程序的特点是服务消费方和服务提供方是本地调用关系. 而一旦踏入公司尤其是大型互 ...
- FIR.im Weekly - 上周微博热转资源精选
LeakCanary: 让内存泄露无所遁形 Square 开源的 LeakCanary,国内开发者 @廖祜秋liaohuqiu 翻译了对应的官方博客,撰写了中文使用说明文档,同时还写了一个小 Demo ...
- iOS开发-代理模式
代理模式有的时候也被称之为委托模式,但是实际上两者是有分别的,代理模式为另一个对象提供一个替身或占位符访问这个对象,代理对象和控制访问对象属于同一类,委托对象和对象不一定属于同一类.两者都可以控制类的 ...
- node.js在windows环境下的安装
node.js官网 https://nodejs.org/en/ Download
- 利用Httponly提升web应用程序安全性
随着www服务的兴起,越来越多的应用程序转向了B/S结构,这样只需要一个浏览器就可以访问各种各样的web服务,但是这样也越来越导致了越来越 多的web安全问题.www服务依赖于Http协议实现,Htt ...
- Level shifting a +/- 2.5V signal to 0 - 5V
Google : Op-Amp Level Shifter Level shifting a +/- 2.5V signal to 0 - 5V I have a front end module t ...