纯代码编写UITabBarController, 不多说,直接见代码

RViewController1 *vc1 = [[RViewController1 alloc]init];

    UINavigationController *navController = [[UINavigationController alloc]initWithRootViewController:vc1];
//只赋值 tabBarItem.title, 通过.title属性取值是取不到值
//navController.tabBarItem.title = @"Page 1"; //相当于对tabBarItem.title 和 navigationItem.title同时赋值
navController.title = @"Page 1";
navController.tabBarItem.image = [UIImage imageNamed:@"1.jpg"]; RViewController2 *vc2 = [[RViewController2 alloc]init];
vc2.title =@"Page 2";
// UITabBarItem *item2 = [[UITabBarItem alloc]initWithTitle:@"Page 2" image:[UIImage imageNamed:@"2.png" ] selectedImage:[UIImage imageNamed:@"2_pressed.png"]];
vc2.tabBarItem.image = [UIImage imageNamed:@"2.png"]; RViewController3 *vc3 = [[RViewController3 alloc]init];
vc3.title =@"Page 3";
vc3.tabBarItem.image = [UIImage imageNamed:@"3.png"]; RViewController4 *vc4 = [[RViewController4 alloc]init];
vc4.title =@"Page 4";
vc4.tabBarItem.image = [UIImage imageNamed:@"4.png"];
vc4.tabBarItem.badgeValue = @""; RViewController5 *vc5 = [[RViewController5 alloc]init]; //创建 UITabItem的实例
UITabBarItem *item1 = [[UITabBarItem alloc]initWithTabBarSystemItem:UITabBarSystemItemHistory tag:];
vc5.tabBarItem = item1; NSArray *controllers = [NSArray arrayWithObjects:navController,vc2,vc3,vc4, nil]; UITabBarController *tabController = [[UITabBarController alloc]init];
tabController.viewControllers = controllers; self.window.rootViewController = tabController;

UITabBarController 初学的更多相关文章

  1. 移动开发:初学 iOS-UIViewController 心得

    初学 iOS,本文翻译了一些 iOS 官网上的 UIViewController 的知识点,如有不到位或不正确的地方,还请指正: 本文所介绍的内容的目标: 理解content view control ...

  2. DDD初学指南

    去年就打算总结一下,结果新换的工作特别忙,就迟迟没有认真动手.主要内容是很多初学DDD甚至于学习很长时间的同学没有弄明白DDD是什么,适合什么情况.这世界上没有银弹,抛开了适合的场景孤立的去研究DDD ...

  3. gulp初学

    原文地址:gulp初学 至于gulp与grunt的区别,用过的人都略知一二,总的来说就是2点: 1.gulp的gulpfile.js  配置简单而且更容易阅读和维护.之所以如此,是因为它们的工作方式不 ...

  4. 初学seaJs模块化开发,利用grunt打包,减少http请求

    原文地址:初学seaJs模块化开发,利用grunt打包,减少http请求 未压缩合并的演示地址:demo2 学习seaJs的模块化开发,适合对seajs基础有所了解的同学看,目录结构 js — —di ...

  5. UITabBarController 升级定制

    UITabBarController 定制 特点 用法 1.准备工作: 加入你的相关图片,放入了Assets.xcassets; 导入Categroy文件夹(这个里面的文件,在这里不详细说明了,有疑问 ...

  6. UITabBarController 基本定制

    UITabBarController 定制 特点 用法 1.准备好你的tabBar图片及其他图片(哈哈哈!!!!),我的图片都放在了Assets.xcassets中. 2.导入本工程中的Categro ...

  7. 自定义UITabBarController标签视图控制器

    首先创建一个类,继承自UItabBarController 然后在.m文件中: 这里我有两个宏定义: #define WIDTH (myView.frame.size.width / 4) //我在写 ...

  8. 混合使用UITabBarController和UINavigationController

    混合使用这两个控件的好处是我们可以在NavigationBar添加更多的东西,如标题,按钮等.让用户能够获得更多的信息. UITabBarController的属性ViewControllers接受以 ...

  9. 基本组件的使用——UITabBarController

    和UINavigationController的作用差不多,UITabBarController也可以在多个UIViewController中切换 这个控件的使用相对简单,只需要为该控件的viewCo ...

随机推荐

  1. CDN原理

    要了解CDN的实现原理,首先让我们来回顾一下网站传统的访问过程,以便理解其与CDN访问方式之间的差别: 由上图可见,传统的网站访问过程为:1. 用户在浏览器中输入要访问的域名:2. 浏览器向域名解析服 ...

  2. MVC中的扩展点(六)ActionResult

    ActionResult是控制器方法执行后返回的结果类型,控制器方法可以返回一个直接或间接从ActionResult抽象类继承的类型,如果返回的是非ActionResult类型,控制器将会将结果转换为 ...

  3. c#集合类的线程安全

    即位于System.Collections命名空间下的集合,如Hashtable,ArrayList,Stack,Queue等.其均提供了线程同步的一个实现 集合线程同步的问题 public clas ...

  4. http://www.cnblogs.com/eye-like/p/4121219.html

    c# 操作Word总结 在医疗管理系统中为保存患者的体检和治疗记录,方便以后的医生或其他人查看.当把数据保存到数据库中,需要新建很多的字段,而且操作很繁琐,于是想到网页的信息创建到一个word文本中, ...

  5. MVC 3.0 在各个版本IIS中的部署

    概述: 最近在做一个MVC 3的项目,在部署服务器时破费了一番功夫,特将过程整理下来,希望可以帮到大家! 本文主要介绍在IIS5.1.IIS6.0.IIS7.5中安装配置MVC 3的具体办法! 正文: ...

  6. codeforce 621B Wet Shark and Bishops

    对角线 x1+y1=x2+y2 或者x1-y1=x2-y2 #include<iostream> #include<string> #include<algorithm& ...

  7. POJ 3450 Corporate Identity kmp+最长公共子串

    枚举长度最短的字符串的所有子串,再与其他串匹配. #include<cstdio> #include<cstring> #include<algorithm> #i ...

  8. 决策树及其python实现

    剪枝 由于悲观错误剪枝 PEP (Pessimistic Error Pruning).代价-复杂度剪枝 CCP (Cost-Complexity Pruning).基于错误剪枝 EBP (Error ...

  9. POJ3356 – AGTC(区间DP&&编辑距离)

    题目大意 给定字符串X和Y,可以对字符串进行一下三种操作: 1.删除一个字符 2.插入一个字符 3.替换一个字符 每个操作代价是1,问运用以上三种操作把X变为Y所需的最小步数是多少? 题解 定义dp[ ...

  10. UVa11584 - Partitioning by Palindromes(区间DP)

    题目大意 给定一个小写字母组成的字符串S,你的任务是划分成尽量少的回文串 题解 方程就是dp[j]=min(dp[i-1]+1)(i<=j,s[i..j]是回文串) 代码: #include&l ...