//
// TabBarViewController.h
// LittleLoveLive
//
// Created by YJ
//
// TabBarViewController.m
// LittleLoveLive
//
// Created by YJ on 16/7/16.
// Copyright © 2016年 YJ. All rights reserved.
// #import "TabBarViewController.h"
#import "RootNavigationController.h"
#import "HomeViewController.h"
#import "LiveViewController.h"
#import "MeViewController.h"
@interface TabBarViewController () @end @implementation TabBarViewController - (void)viewDidLoad {
[super viewDidLoad]; [self setupTheLine];
[self initialControllers]; } //初始化子控制器
-(void)initialControllers { [self setupController:[[HomeViewController alloc]init] image:@"icon_home_normal.png" selectedImage:@"icon_home_pressed.png" title:nil];
[self setupController:[[LiveViewController alloc]init] image:@"icon_live_normal.png" selectedImage:@"icon_live_pressed.png" title:nil];
[self setupController:[[MeViewController alloc] init] image:@"icon_me_normal.png" selectedImage:@"icon_me_pressed.png" title:nil]; } //设置控制器
-(void)setupController:(UIViewController *)childVc image:(NSString *)image selectedImage:(NSString *)selectedImage title:(NSString *)title { //标题
childVc.title = title;
//childVc.view.backgroundColor = RGBACOLOR(239.0f, 239.0f, 244.0f, 1.0f); //tabBarItem图片
childVc.tabBarItem.image = [[UIImage imageNamed:image] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
childVc.tabBarItem.selectedImage = [[UIImage imageNamed:selectedImage]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; //tabBarItem字体的设置
//正常状态
NSMutableDictionary *normalText = [NSMutableDictionary dictionary];
normalText[NSForegroundColorAttributeName] = [UIColor colorWithRed:/255.0 green:/255.0 blue:/255.0 alpha:1.0];
[childVc.tabBarItem setTitleTextAttributes:normalText forState:UIControlStateNormal]; //选中状态
NSMutableDictionary *selectedText = [NSMutableDictionary dictionary];
selectedText[NSForegroundColorAttributeName] = [UIColor blackColor];
[childVc.tabBarItem setTitleTextAttributes:selectedText forState:UIControlStateSelected]; RootNavigationController *nav = [[RootNavigationController alloc]initWithRootViewController:childVc];
[self addChildViewController:nav]; } //设置分割线
-(void)setupTheLine { UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(, -, self.tabBar.frame.size.width, self.tabBar.frame.size.height)];
[imageView setImage:[UIImage imageNamed:@"bg_tabbar"]];
[imageView setContentMode:UIViewContentModeCenter];
[self.tabBar insertSubview:imageView atIndex:];
//覆盖原生Tabbar的上横线
[[UITabBar appearance] setShadowImage:[self createImageWithColor:[UIColor clearColor]]];
[[UITabBar appearance] setBackgroundImage:[self createImageWithColor:[UIColor clearColor]]];
//设置TintColor
// UITabBar.appearance.tintColor = [UIColor orangeColor]; } -(UIImage*) createImageWithColor:(UIColor*) color
{
CGRect rect=CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [color CGColor]);
CGContextFillRect(context, rect);
UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return theImage;
} //设置中间按钮不受TintColor影响
- (void)awakeFromNib {
[super awakeFromNib];
NSArray *items = self.tabBar.items;
//设置第几个 tabBar不受影响
UITabBarItem *btnAdd = items[];
btnAdd.image = [btnAdd.image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
btnAdd.selectedImage = [btnAdd.selectedImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
} - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} @end

 on 16/7/16.
// Copyright © 2016年 YJ. All rights reserved.
// #import <UIKit/UIKit.h> @interface TabBarViewController : UITabBarController @end

最新文章

  1. Javascript学习笔记:2种其他类型转换为数字Number类型的方式
  2. Linux3:more、which、find、chmod、tar、diff、grep、ps、netstat、uname
  3. ubuntu tomcat 部署java web
  4. Objective-C中@encode的使用
  5. PHP后门隐藏与维持技巧
  6. AngularJs学习笔记--Guide教程系列文章索引
  7. 【web安全】第六弹:手工SQL注入详解
  8. 使用text-overflow:ellipsis对溢出文本显示省略号有两个好处
  9. JSP中使用cookie存储中文
  10. 【移动开发】binder阻塞/非阻塞与单向/双向的问题
  11. Centos安装Nginx(转载)
  12. 简单的OO ALV小示例
  13. Java HashMap的put操作(Java1.8)
  14. 树莓派安装cobbler,自动化安装CentOS
  15. L298 猴子进化过程
  16. Eureka 源码编译 部署
  17. sqlserver 修改表字段长度
  18. Cognos开发ContentManagerServiceStub不能转换为Stub
  19. Hexo快速搭建静态博客并实现远程VPS自动部署
  20. Apache Kafka Replication Design &ndash; High level

热门文章

  1. NodeJS:树的反序列化
  2. Running a Remote Desktop on a Windows Azure Linux VM (远程桌面到Windows Azure Linux )-摘自网络(试了,没成功 - -!)
  3. Struts2类型转换器
  4. JSF 2 password example
  5. Educational Codeforces Round 7 - E. Ants in Leaves
  6. HDU2066一个人的旅行(dijkstra)
  7. Windows Server2008 R2 MVC 环境配置
  8. HttpModule的认识与深入理解及MVC运行机制
  9. C#全角半角转换函数
  10. CSS基础(03)