[objc] view
plain
copy

  1. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
  2. {
  3. self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
  4. // Override point for customization after application launch.
  5. self.window.backgroundColor = [UIColor whiteColor];
  6. #pragma mark - 设置tabBarItem
  7. #pragma mark  第一个视图ViewController
  8. HMT_AViewController * tabBarViewA = [[HMT_AViewController alloc] init];
  9. // 设置A视图下----标签栏标题文字(可參照微信或者QQ体会)
  10. tabBarViewA.tabBarItem.title = @"微信";
  11. // 设置A视图下----标签栏图片(由于自己没有图片,在这里随便设置了个名字)
  12. //tabBarViewA.tabBarItem.image = [UIImage imageNamed:@"1.png"];
  13. // 设置A视图下----标签栏信息提示(住:badgeValue是NSString类型 例如以下设置了3,就像QQ消息有3条未接受一样,给人一种提醒)
  14. tabBarViewA.tabBarItem.badgeValue = @"3";
  15. // ios7弃用了----标签栏选中的时候显示一张图片,没选中的时候显示还有一张图片
  16. //[tabBarViewA.tabBarItem setFinishedSelectedImage:actionMenu.selectedIcon withFinishedUnselectedImage:actionMenu.icon];
  17. // ios7的方法(自己没有图片,所以代码里面的图片都是一个随便取的名字,没有有用意义)
  18. //tabBarViewA.tabBarItem.selectedImage = actionMenu.selectedIcon;
  19. #pragma mark  第二个视图ViewController
  20. // 第二个视图ViewController
  21. HMT_BViewController * tabBarViewB = [[HMT_BViewController alloc] init];
  22. // 设置B视图下----标签栏
  23. // 用系统提供的标识(能够算等价于图标和文字)进行设置(參数:UITabBarSystemItem是个枚举值,想要什么形式,就去系统提供的API中找)
  24. tabBarViewB.tabBarItem = [[UITabBarItem alloc]initWithTabBarSystemItem:UITabBarSystemItemSearch tag:1];
  25. // 设置B视图下----标签栏信息提示
  26. tabBarViewB.tabBarItem.badgeValue = @"GO";
  27. #pragma mark  第三个视图ViewController
  28. HMT_CViewController * tabBarViewC = [[HMT_CViewController alloc] init];
  29. tabBarViewC.tabBarItem = [[UITabBarItem alloc]initWithTabBarSystemItem:UITabBarSystemItemDownloads tag:2];
  30. // 设置B视图下----标签栏信息提示
  31. tabBarViewC.tabBarItem.badgeValue = @"new";
  32. #pragma mark  第四个视图ViewController
  33. HMT_DViewController * tabBarViewD = [[HMT_DViewController alloc] init];
  34. tabBarViewD.tabBarItem = [[UITabBarItem alloc]initWithTabBarSystemItem:UITabBarSystemItemFavorites tag:3];
  35. // 设置B视图下----标签栏信息提示
  36. tabBarViewD.tabBarItem.badgeValue = @"99";
  37. #pragma mark  第五个视图ViewController
  38. HMT_EViewController * tabBarViewE = [[HMT_EViewController alloc] init];
  39. tabBarViewE.tabBarItem = [[UITabBarItem alloc]initWithTabBarSystemItem:UITabBarSystemItemHistory tag:4];
  40. // 设置B视图下----标签栏信息提示
  41. tabBarViewE.tabBarItem.badgeValue = @"sky";
  42. #pragma mark  第六个视图ViewController(系统默认能显示的最大视图个数是5个)
  43. /* 假设你的viewControllers属性加入了多于五个的items,那tab bar controller将会自己主动插入一个特殊的view controller,
  44. 称为 More view controller,该 controller 将会负责管理多于的items,这个More view controller提供一个自己定义的界面,
  45. 用table的方式呈现多余的view controller。而且view controller的数量是不限制的*/
  46. HMT_FViewController * tabBarViewF = [[HMT_FViewController alloc] init];
  47. tabBarViewF.tabBarItem = [[UITabBarItem alloc]initWithTabBarSystemItem:UITabBarSystemItemContacts tag:5];
  48. // 设置F视图下----标签栏信息提示
  49. tabBarViewF.tabBarItem.badgeValue = @"AG";
  50. #pragma mark - 设置TabBarController
  51. // 创建TabBarController
  52. UITabBarController * tabBarController = [[UITabBarController alloc]init];
  53. // TabBarController默认是放在最底部的,假设你想调整位置,能够进行以下2部操作(44是iPhone中TabBarController和UINavigationController标准高度)
  54. //CGRect frame = CGRectMake(0, 20, 320, 44);
  55. //tabBarController.tabBar.frame = frame;
  56. // 每个tab都必须有一个content view controller------->viewControllers属性,用来存入一个应用的TabBarController有多少个界面切换
  57. tabBarController.viewControllers = [NSArray arrayWithObjects:tabBarViewA,tabBarViewB,tabBarViewC,tabBarViewD,tabBarViewE,tabBarViewF, nil nil];
  58. // 设置着色
  59. tabBarController.tabBar.tintColor = [UIColor greenColor];
  60. // 设置选中图片时候
  61. tabBarController.tabBar.selectedImageTintColor = [UIColor brownColor];
  62. // 设置背景图片(自己没有图片,不进行设置)
  63. //tabBarController.tabBar.backgroundImage = [UIImage imageNamed:@"@@@@@"];
  64. // 设置程序启动时默认的ViewController视图(设置为3,一共5个ViewController,进来时候显示的视图就是第4个-tabBarViewD,下标从0開始)
  65. tabBarController.selectedIndex = 3;
  66. self.window.rootViewController = tabBarController;
  67. [self.window makeKeyAndVisible];
  68. return YES;
  69. }

@最后效果例如以下图:

watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvenVveW91MTMxNA==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="">

版权声明:本文博主原创文章,博客,未经同意不得转载。

UITabBarController详细说明(简介和设置)的更多相关文章

  1. UITabBarController 、TabBar背景颜色设置,UITabBarItem的文字样式(颜色和大小)UITabBarItem的位置调整

    改变UITabBarController的颜色 UIView*mView=[[UIView alloc]initWithFrame:CGRectMake(0,0,320,48)];//这是部分tabb ...

  2. Keepalived详细介绍简介

    1.1.Keepalived简介 Keepalived是Linux下一个轻量级别的高可用解决方案.高可用(High Avalilability,HA),其实两种不同的含义:广义来讲,是指整个系统的高可 ...

  3. 详细:idea如何设置类头注释和方法注释

    IntelliJ IDEA 类注释和自定义方法注释   来源:https://my.oschina.net/baishi/blog/617478#navbar-header intellj idea的 ...

  4. CentOS6.6图文详细安装教程(有些设置大部分教程没出现过,附带网络设置等)

    作者:Sungeek 出处:http://www.cnblogs.com/Sungeek/ 欢迎转载,也请保留这段声明.谢谢! Centos6.6 下载地址:thunder://QUFodHRwOi8 ...

  5. 【开发技术】Eclipse插件Call Hierarchy简介及设置

    Call Hierarchy 主要功能是 显示一个方法的调用层次(被哪些方法调,调了哪些方法) 在MyEclipse里Help - Software updates - Find and instal ...

  6. linux设置iptables防火墙的详细步骤(centos防火墙设置方法)

    CentOS系统也是基于linux中的它的防火墙其实就是iptables了,下面我来介绍在CentOS防火墙iptables的配置教程,希望此教程对各位朋友会有所帮助.   iptables是与Lin ...

  7. 虚拟机VMWare安装苹果系统MacOS详细教程(联网设置,全屏插件、文件互传)

    运行环境: VMware® Workstation 12 Pro(自行安装,或者用这个) 推荐(下面以10.11.6版本做的教程,但是安装时推荐使用此版本安装然后升级到10.11.6):MacOS X ...

  8. MySQL - binlog日志简介及设置

    基本概念 binlog是Mysql sever层维护的一种二进制日志,与innodb引擎中的redo/undo log是完全不同的日志:其主要是用来记录对mysql数据更新或潜在发生更新的SQL语句, ...

  9. thinkphp路由简介和设置使用

    use think\Route; //静态路由 Route::rule('/', 'index/index/index'); Route::rule('test', 'index/index/test ...

随机推荐

  1. groovy : 正則表達式

    groovy 正則表達式 企图模仿Perl 的语法,结果是我试用后.发现没法提取匹配的字符串. 还是直接引用 java.util.regex  负责对字符序列进行正則表達式匹配 先转载水木清华上的样例 ...

  2. cocos2d-x游戏开发 跑酷(四) 关联与物理世界

    原创.转载注明出处http://blog.csdn.net/dawn_moon/article/details/21451077 前面一节尽管实现了一个跑动的人物,可是他只不过一个精灵在运行一个跑动的 ...

  3. Git中的merge命令实现和工作方式

    想象一下有例如以下情形:代码库中存在两个分支,而且每一个分支都进行了改动.最后你想要将当中的一个分支合并到其它的分支中.个人博客网址 http://swinghu.github.com/ 那么要问合并 ...

  4. ZooKeeper安装与运行

    ZooKeeper安装与运行 首先从官网下载ZooKeeper压缩包,然后解压下载得到的ZooKeeper压缩包,发现有“bin,conf,lib”等目录.“bin目录”中存放有运行脚本:“conf目 ...

  5. Cocos2d-x 3.1.1 Lua实例-AccelerometerTest(重力加速计)

    Cocos2d-x 3.1.1 Lua实例-AccelerometerTest(重力加速计) 本篇博客介绍Cocos2d-x的第一个实例--重力加速计測试.效果图(注:这里无法模拟重力感应): --[ ...

  6. 开源 java CMS - FreeCMS2.3 留言管理

    原文地址:http://javaz.cn/site/javaz/site_study/info/2015/22027.html 项目地址:http://www.freeteam.cn/ 留言管理 管理 ...

  7. Activity数据传输到服务

    activity数据接口负责启动该服务包.service获取数据.手术. 详细demo如下面: package com.example.android_service_trance; import a ...

  8. atitit.高级编程语言的特性 and 未来趋势与进化.doc

    atitit.高级编程语言的特性 and 未来趋势与进化.doc 1 编程语言的发展历程 1 1.1 编程语言的进化,起始发现背后的思想 :不论什么两个系统之间的复杂性,都能够通过加入一个抽象层要屏蔽 ...

  9. pan

    百度云盘地址第一季http://pan.baidu.com/share/link?shareid=198342&uk=1191518428第二季http://pan.baidu.com/sha ...

  10. [置顶] hdu 4699 2个栈维护 or 伸展树

    hdu 4699  Editor 题意:对一个数列进行操作,光标位置后面插入一个权值为x的数,删除光标前的那个数,光标左移一位,光标右移一位,求到k位置的最大的前缀和.. 注意这里的k是在光标之前的, ...