TabBarController
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的更多相关文章
- 从tabBarController的一个item上的控制器跳转到另一个item上的控制器
先从习惯性的tabBarController开始,很多应用的外框都是用这个开始的,而从tabBarController的一个item上的控制器跳转到另一个上的,往往都是直接通过点击tabBar上的不同 ...
- 整合TabBarController与NavigationController
一.项目结构 一开始创建一个空的项目
- storyboard tabbarcontroller设置tab的图片
在storyboard里逐项设置了图片,咦,怎么是颜色?别急,慢慢来 找到你的tabbarcontroller指向的viewcontroller,在viewdidload里做如下事,搞定 - (voi ...
- iOS:CYLTabBarController【低耦合集成TabBarController】
导航 与其他自定义TabBarController的区别 集成后的效果 项目结构 使用CYLTabBarController 第一步:使用CocoaPods导入CYLTabBarController ...
- 使用TabBarController(代码实现)
step01:使用Xcode创建一个项目 step02:填写项目必要信息 step03:检查文件结构树是否正确 step04:创建一些类,这些类将会在后面用到!(选择Swift File) step0 ...
- app整体搭建环境:tabBar切换不同控制器的封装(自定义导航+自定义uiviewcontroler+系统自带tabbar+自定义tabbarController)
首先,一个app的搭建环境非常重要.既要实现基本功能,又要考虑后期优化的性能. 现在很多应用不仅仅是系统自带的控制器,由于需求复杂,基本上需要自定义多控制器来管理. 新建一个BasicNavigati ...
- iOS 在使用UINavigationController和TabBarController时view的frame
可能是以前记错了,总认为在ios6上使用了UINavigationController或者TabBarController会因为多了bar而影响子controller的view的frame大小.今天在 ...
- iOS开发 tabBarController选中状态
self.tabBarController.selectedIndex = 0; // 默认是0:
- 自定义TabBarController报错 - Unbalanced calls to begin/end appearance transitions for <>
自定义了TabBarController 之后必须实现以下方法才能避免报错 -(void)viewWillAppear:(BOOL)animated { [self.selectedViewContr ...
随机推荐
- 之一:CABasicAnimation - 基本动画
嗷呜嗷呜嗷呜 // 将视图作为属性方便后面执行多个不同动画 _myView = [[UIView alloc] init]; _myView.layer.position = CGPointMake( ...
- html前端总结
1.设置图片的最大宽高的css<style> .img-max { max-height:50px; width:expression(document.body.clientHeight ...
- Fragment与FragmentActivity的关系
前阵用viewpaper+fragment做滑动引导,查阅了下网上的资料,发现在有两种做法,一个是自建类直接继承Activity另一种是继承FragmentActivity,很是迷惑,在查了些goog ...
- UILabel用法
// UILabel -> UIView // UILabel用来显示文字内容 //创建一个Label,一般都直接通过initWithFrame确定位置跟大小 UILabel *lb = [[U ...
- AndRoid studio创建APP图标
打开---File----New----Image asset 注意:在design页面可能没有image asset选项!必须在其他编辑页面! 这就打开了图标设置页面,找到自己想要的图标就好!下面框 ...
- 【代码笔记】iOS-3DES+Base64加密解密
一,工程目录. 二,代码. RootViewController.m #import "RootViewController.h" #import "NSString+T ...
- Asp.net Mvc 多级控制器 路由重写 及 多级Views目录 的寻找视图的规则 (多级路由) 如:Admin/Test/Index
http://blog.csdn.net/buhuan123/article/details/26387427 目录(?)[-] 1那么我们再来看我们需要的访问方式如下图 razor视图的地址写成通配 ...
- 试用 Nexus OSS 3.0 的docker仓库 (二)
试用 Nexus OSS 3.0 的docker仓库 (一) : http://www.cnblogs.com/wzy5223/p/5410990.html 三. 创建docker私有仓库,docke ...
- mysql源码解读之事务提交过程(一)
mysql是一种关系型数据库,关系型数据库一个重要的特性就是支持事务,这是区别于no-sql产品的一个核心特性.当然了,no-sql产品支持键值查询,不能支持sql语句,这也是一个区别.今天主要讨论下 ...
- zookeeper barrier和queue应用实例
package org.windwant.zookeeper; import org.apache.zookeeper.CreateMode; import org.apache.zookeeper. ...