1.两种方式创建系统TabBarController

-(id)init{
self = [super init];
if( self )
{ //newTask
HSNewTaskViewController *newsTaskVc = [[HSNewTaskViewController alloc] init];
[self addChildViewController:newsTaskVc title:@"新任务" normalImage:@"tabbar_NewTask_normal" selectImage:@"tabbar_NewTask_select"];
//actioning
HSProcessingViewController *actioningVc = [[HSProcessingViewController alloc] init];
[self addChildViewController:actioningVc title:@"进行中" normalImage:@"tabbar_processing_normal" selectImage:@"tabbar_processing_select"];
//completed
HSCompletedViewController *completedVc = [[HSCompletedViewController alloc] init];
[self addChildViewController:completedVc title:@"已完成" normalImage:@"tabbar_completed_normal" selectImage:@"tabbar_completed_select"]; }
return self;
} /**
* 添加一个子控制器
*
* @param childVc 子控制器对象
* @param title 标题
* @param imageName 图标
* @param selectedImageName 选中的图标
*/
- (void)addChildViewController:(UIViewController *)childController title:(NSString *)title normalImage:(NSString *)normalImage selectImage:(NSString *)selectImage{ childController.tabBarItem.title = title;
[childController.tabBarItem setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:11.0]}
forState:UIControlStateNormal];
[childController.tabBarItem setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:11.0],
NSForegroundColorAttributeName:[UIColor colorWithRed:/255.0 green:/255.0
                               blue:/255.0 alpha:1.0]}
forState:UIControlStateSelected]; childController.tabBarItem.image = [[UIImage imageNamed:normalImage] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
childController.tabBarItem.selectedImage = [[UIImage imageNamed:selectImage] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; [self addChildViewController:childController];
//第二种添加方式
// self.viewControllers=@[c1,c2,c3,c4];
}

TabBarController的更多相关文章

  1. 从tabBarController的一个item上的控制器跳转到另一个item上的控制器

    先从习惯性的tabBarController开始,很多应用的外框都是用这个开始的,而从tabBarController的一个item上的控制器跳转到另一个上的,往往都是直接通过点击tabBar上的不同 ...

  2. 整合TabBarController与NavigationController

    一.项目结构 一开始创建一个空的项目

  3. storyboard tabbarcontroller设置tab的图片

    在storyboard里逐项设置了图片,咦,怎么是颜色?别急,慢慢来 找到你的tabbarcontroller指向的viewcontroller,在viewdidload里做如下事,搞定 - (voi ...

  4. iOS:CYLTabBarController【低耦合集成TabBarController】

    导航 与其他自定义TabBarController的区别 集成后的效果 项目结构 使用CYLTabBarController 第一步:使用CocoaPods导入CYLTabBarController ...

  5. 使用TabBarController(代码实现)

    step01:使用Xcode创建一个项目 step02:填写项目必要信息 step03:检查文件结构树是否正确 step04:创建一些类,这些类将会在后面用到!(选择Swift File) step0 ...

  6. app整体搭建环境:tabBar切换不同控制器的封装(自定义导航+自定义uiviewcontroler+系统自带tabbar+自定义tabbarController)

    首先,一个app的搭建环境非常重要.既要实现基本功能,又要考虑后期优化的性能. 现在很多应用不仅仅是系统自带的控制器,由于需求复杂,基本上需要自定义多控制器来管理. 新建一个BasicNavigati ...

  7. iOS 在使用UINavigationController和TabBarController时view的frame

    可能是以前记错了,总认为在ios6上使用了UINavigationController或者TabBarController会因为多了bar而影响子controller的view的frame大小.今天在 ...

  8. iOS开发 tabBarController选中状态

    self.tabBarController.selectedIndex = 0;  // 默认是0:

  9. 自定义TabBarController报错 - Unbalanced calls to begin/end appearance transitions for <>

    自定义了TabBarController 之后必须实现以下方法才能避免报错 -(void)viewWillAppear:(BOOL)animated { [self.selectedViewContr ...

随机推荐

  1. Ioc容器Autofac系列(1)-- 初窥

     一.前言 第一次接触Autofac是因为CMS系统--Orchard,后来在一个开源爬虫系统--NCrawler中也碰到过,随着深入了解,我越发觉得Ioc容器是Web开发中必不可少的利器.那么,Io ...

  2. SAML : A SAML stack

    http://nzpcmad.blogspot.co.nz/2013/06/saml-saml-stack.html You have an application – .NET, JAVA what ...

  3. 更新CocoaPods碰到的问题及知识点

    1:解决CocoaPods安装时报的问题,http://ruby.taobao.org/latest_specs.4.8.gz 报404 解决 bad response Not Found 404 ( ...

  4. 【代码笔记】iOS-点击一个button,出6个button

    一,效果图. 二,工程图. 三,代码. RootViewController.h #import <UIKit/UIKit.h> //加入头文件 #import "DCPathB ...

  5. 【读书笔记】iOS网络-使用推送通知

    一,本地通知 本地通知有64位的最大限制.虽然,你依然可以调度通知,不过到到达的通知数被限定为接近64个,并且按照fireDate的顺序排序,系统会忽略掉其余的通知.这意味着如果现在有64个调用的本地 ...

  6. unity3D 常用快捷键

    http://blog.csdn.net/ganlijianstyle/article/details/7985509 此页面提供了Unity3D默认的快捷键. shift +方向键         ...

  7. php示例代码之empty函数

    1 2 3 4 5 6 7 8 9 10 11 <?php     $testVar=0;   if(empty($testVar))   {     echo 'msg:true';   } ...

  8. linux 学习随笔-group和user管理

    1:/etc/passwd 打开该文件,可以看到每一行内容被分割成了7个字段比如:root:x:0:0:root:/root:/bin/bash 第一个字段表示用户名为root用户 第二个字段存放了该 ...

  9. 机器数据的价值 - Web 访问日志和数据库审计日志

    计算机数据 大量的数据流,不断增长的来源,蕴含着巨大的价值 在 Splunk,我们大量谈及计算机数据.这些数据是指在数据中心.“物联网”和互联设备世界中运行的所有系统产生的数据.其中包括支撑组织的应用 ...

  10. ADDM Reports bug:Significant virtual memory paging was detected on the host operating system

    查看ADDM(数据库版本为ORACLE 10.2.0.5.0)报告时,发现其中有个结论非常不靠谱:Significant virtual memory paging was detected on t ...