CYLTabBarController的简单使用
#pragma mark- 登录成功跳转至主页
-(void)jumpToMainVC {
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent; NSArray *normalImage = @[@"notice_icon_normal", @"news_icon_normal", @"contacts_icon_normal", @"application_icon_normal"];
NSArray *selectImage = @[@"notice_icon_pressed", @"news_icon_pressed", @"contacts_icon_pressed", @"application_icon_pressed"];
NSArray *vcClass = @[@"NotifyViewController", @"NewsViewController", @"ContactsViewController", @"ApplicationViewController"];
NSArray *titleArray = @[@"通知", @"新闻", @"联系人", @"应用"];
NSMutableArray *allArray = [NSMutableArray array]; for (int i = ; i < ; i++) {
Class cla = NSClassFromString(vcClass[i]);
UIViewController *vc = [[cla alloc] init];
vc.navigationItem.title = titleArray[i];
[vc.tabBarItem setTitle:titleArray[i]];
[vc.tabBarItem setImage:[[UIImage imageNamed:normalImage[i]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
[vc.tabBarItem setSelectedImage:[[UIImage imageNamed:selectImage[i]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
BaseNavigationController *nav = [[BaseNavigationController alloc] initWithRootViewController:vc];
[allArray addObject:nav];
}
UITabBarController *tab = [[UITabBarController alloc] init];
tab.viewControllers = allArray; //设置navigationBar样式
[self setUpNavigationBarAppearance];
//tabBarItem 的选中和不选中文字属性
[self setUpTabBarItemTextAttributes]; self.window.rootViewController = tab; //打开收藏的数据库
[[CollectDataCenter shareInstance] openDataBase];
} /**
* 设置navigationBar样式
*/
- (void)setUpNavigationBarAppearance {
UINavigationBar *navigationBarAppearance = [UINavigationBar appearance];
UIImage *backgroundImage = nil;
NSDictionary *textAttributes = nil; if (NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_6_1) {
backgroundImage = [UIImage imageNamed:@"navigationBar_BG"]; textAttributes = @{
NSFontAttributeName: [UIFont boldSystemFontOfSize:],
NSForegroundColorAttributeName: [UIColor whiteColor],
};
} else {
#if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_7_0
backgroundImage = [UIImage imageNamed:@"navigationBar_BG"]; textAttributes = @{
UITextAttributeFont: [UIFont boldSystemFontOfSize:],
UITextAttributeTextColor: [UIColor blackColor],
UITextAttributeTextShadowColor: [UIColor clearColor],
UITextAttributeTextShadowOffset: [NSValue valueWithUIOffset:UIOffsetZero],
};
#endif
} [navigationBarAppearance setBackgroundImage:backgroundImage
forBarMetrics:UIBarMetricsDefault];
[navigationBarAppearance setTitleTextAttributes:textAttributes];
} /**
* tabBarItem 的选中和不选中文字属性
*/
- (void)setUpTabBarItemTextAttributes { // 普通状态下的文字属性
NSMutableDictionary *normalAttrs = [NSMutableDictionary dictionary];
normalAttrs[NSForegroundColorAttributeName] = RGBA(, , , ); // 选中状态下的文字属性
NSMutableDictionary *selectedAttrs = [NSMutableDictionary dictionary];
selectedAttrs[NSForegroundColorAttributeName] = RGBA(, , , ); // 设置文字属性
UITabBarItem *tabBar = [UITabBarItem appearance];
[tabBar setTitleTextAttributes:normalAttrs forState:UIControlStateNormal];
[tabBar setTitleTextAttributes:selectedAttrs forState:UIControlStateSelected]; // 设置背景图片
UITabBar *tabBarAppearance = [UITabBar appearance];
[tabBarAppearance setBackgroundImage:[UIImage imageNamed:@"tabbarBG"]];
// tabBarAppearance.barTintColor = [UIColor lightGrayColor];
} 显示界面显示如下:
CYLTabBarController的简单使用的更多相关文章
- iOS:CYLTabBarController【低耦合集成TabBarController】
导航 与其他自定义TabBarController的区别 集成后的效果 项目结构 使用CYLTabBarController 第一步:使用CocoaPods导入CYLTabBarController ...
- 【造轮子】打造一个简单的万能Excel读写工具
大家工作或者平时是不是经常遇到要读写一些简单格式的Excel? shit!~很蛋疼,因为之前吹牛,就搞了个这东西,还算是挺实用,和大家分享下. 厌烦了每次搞简单类型的Excel读写?不怕~来,喜欢流式 ...
- Fabio 安装和简单使用
Fabio(Go 语言):https://github.com/eBay/fabio Fabio 是一个快速.现代.zero-conf 负载均衡 HTTP(S) 路由器,用于部署 Consul 管理的 ...
- node.js学习(三)简单的node程序&&模块简单使用&&commonJS规范&&深入理解模块原理
一.一个简单的node程序 1.新建一个txt文件 2.修改后缀 修改之后会弹出这个,点击"是" 3.运行test.js 源文件 使用node.js运行之后的. 如果该路径下没有该 ...
- 哪种缓存效果高?开源一个简单的缓存组件j2cache
背景 现在的web系统已经越来越多的应用缓存技术,而且缓存技术确实是能实足的增强系统性能的.我在项目中也开始接触一些缓存的需求. 开始简单的就用jvm(java托管内存)来做缓存,这样对于单个应用服务 ...
- 在Openfire上弄一个简单的推送系统
推送系统 说是推送系统有点大,其实就是一个消息广播功能吧.作用其实也就是由服务端接收到消息然后推送到订阅的客户端. 思路 对于推送最关键的是服务端向客户端发送数据,客户端向服务端订阅自己想要的消息.这 ...
- 我的MYSQL学习心得(一) 简单语法
我的MYSQL学习心得(一) 简单语法 我的MYSQL学习心得(二) 数据类型宽度 我的MYSQL学习心得(三) 查看字段长度 我的MYSQL学习心得(四) 数据类型 我的MYSQL学习心得(五) 运 ...
- 使用 Nodejs 搭建简单的Web服务器
使用Nodejs搭建Web服务器是学习Node.js比较全面的入门教程,因为要完成一个简单的Web服务器,你需要学习Nodejs中几个比较重要的模块,比如:http协议模块.文件系统.url解析模块. ...
- ASP.NET Aries 入门开发教程2:配置出一个简单的列表页面
前言: 朋友们都期待我稳定地工作,但创业公司若要躺下,也非意念可控. 若人生注定了风雨飘摇,那就雨中前行了. 最机开始看聊新的工作机会,欢迎推荐,创业公司也可! 同时,趁着自由时间,抓紧把这系列教程给 ...
随机推荐
- 解决在macOS下安装了python却没有pip命令的问题【经验总结】
可以使用brew直接安装python,但是安装完成了之后没有pip命令. pip是常用的python包管理工具,类似于java的maven.第一反应brew install pip,却提示没这货. 可 ...
- 清除MSSQL历史记录
declare @dt datetime select @dt = cast(N'2019-05-21T14:13:45' as datetime) exec msdb.dbo.sp_delete_b ...
- 使用bootstrap的栅格布局,用row后出现横向滚动条
原因: **row默认有:margin-left:-15px; margin-right:-15px: 解决办法: **row外层需要包裹container或者container-fluid,一句话就 ...
- 01_Tutorial 1: Serialization 序列化
1.序列化 1.官方教程 https://q1mi.github.io/Django-REST-framework-documentation/tutorial/1-serialization_zh/ ...
- Kylin介绍 (很有用)
转:http://blog.csdn.net/yu616568/article/details/48103415 Kylin是ebay开发的一套OLAP系统,与Mondrian不同的是,它是一个MOL ...
- neo4j查询语句
一:查询 比较操作: = <> < > <= >= 布尔操作: AND OR NOT XOR 1.把节点的前两个字为"提示"的节点去除" ...
- 1卸载ROS
sudo apt-get purge ros-*sudo rm -rf /etc/rosgedit ~/.bashrc 参考: https://blog.csdn.net/xmy306538517/a ...
- Hadoop Aggregate Resource Allocation解释
1.在hadoop里面运行程序的时候,查看某个任务的具体信息如下: [hadoop@master monitor]$ yarn application -list 如上图,这里面的Aggregate ...
- cmake入门之内部构建
https://www.cnblogs.com/coderfenghc/tag/cmake/ https://cmake.org/cmake/help/v3.16/guide/tutorial/ind ...
- Docker:Docker Compose 详解
Docker Compose 概述与安装? 前面我们使用 Docker 的时候,定义 Dockerfile 文件,然后使用 docker build.docker run 等命令操作容器.然而微服务架 ...