UITabBarController详细说明(简介和设置)

UITabBarController详细说明(简介和设置)

大家好,又见面了,我是全栈君,今天给大家准备了Idea注册码。

UITabBarController详细说明(简介和设置)

UITabBarController详细说明(简介和设置)

[objc] 
view plain
copy
在CODE上查看代码片
派生到我的代码片

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


@最后效果例如以下图:


UITabBarController详细说明(简介和设置)

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

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/116845.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • CCriticalSection与CSingleLock

    CCriticalSection与CSingleLockCCriticalSectionAnobjectofclassCCriticalSectionrepresentsa“criticalsection”—asynchronizationobjectthatallowsonethreadatatimetoaccessaresourceorsectionofcode.Criticalse

    2022年7月21日
    15
  • arcgis python 教程-ArcGIS Python 入门到精通,视频教程下载

    arcgis python 教程-ArcGIS Python 入门到精通,视频教程下载课程介绍:本课程15章42个视频,基于ArcGIS10.2版本,涵盖了如何使用Python开发ArcGIS自定义工具,具体包括:编辑器的使用安装;列表函数使用;汉字乱码处理;游标(cursor)查询、更新和插入;几何图形生成和坐标导出;属性查询和空间查询;字段映射(FieldMappings)和值表(ValueTable)使用;拓扑检查和创建的拓扑处理;文件TXT、XLS和ArcGIS数据转换;使…

    2022年6月26日
    35
  • 请描述django模板中标签的作用?_抽奖券模板

    请描述django模板中标签的作用?_抽奖券模板常用的模板标签if标签if标签相当于Python中的if语句,有elif和else相对应,但是所有的标签都需要用标签符号({%%})进行包裹。if标签中可以使用==、!=、<、<=、&

    2022年7月29日
    7
  • 铸博皇御:贵金属技术分析基础入门知识「建议收藏」

    铸博皇御:贵金属技术分析基础入门知识「建议收藏」 在贵金属投资市场上,或许有很多投资者表示贵金属技术分析很难理解。特别是刚入门的新手,可能一开始对其并不容易理解,其实这可以理性地看待。贵金属技术分析是根据历史数据,以及开盘价、收盘价、最高价、最低价,利用数学统计的方法来进行综合统计计算。  一般进行分析时需要抛弃主观观念,客观地去分析价格的走向。虽然它不能够左右价格走向,但是可以由价格决定它的趋势走向。所以能不能学好贵金属技术分析,是多方面作用的结果。但需要提醒大家的是:用贵金属技术分析法,只能分析它的趋势,意味着不能完全依赖技术分析来行情作为决策重

    2022年5月28日
    39
  • RabbitMQ Network Partitions

    RabbitMQ Network PartitionsClusteringandNetworkPartitionsRabbitMQclustersdonottoleratenetworkpartitionswell.IfyouarethinkingofclusteringacrossaWAN,don’t.Youshouldusefederationortheshovelinstead.H

    2022年6月26日
    29
  • 前端程序员的日常工作_国外程序员生活的一天

    前端程序员的日常工作_国外程序员生活的一天程序员的生活很简单,天天对着电脑,偶尔休息了也在家看看电影,打打游戏,作为一枚前端,我简单的说下,我这天天的生活吧早上起来的时候,一般都是8:30上班,然后定闹钟定到6:30一个6:40一个6:50一个然后到7:00的时候再响就开始抱怨,今天晚上一定要早点谁,然后起来,穿衣服,上厕所,刷牙洗脸,二十分钟搞定。在路边买两个包子,然后去挤公交或者地铁,人山人海啊正好8:30到公司,好不容易来…

    2022年4月19日
    49

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号