iphone – UITabBarController的程序创建和配置 – 为选项卡设置系统映像

iphone – UITabBarController的程序创建和配置 – 为选项卡设置系统映像,第1张

概述以编程方式在app中创建tabBar非常简单: self.tabBarController = [[UITabBarController alloc] init]; [self.view addSubview:_tabBarController.view];UIViewController * tab1 = [[UIViewController alloc] init];tab1.titl 以编程方式在app中创建tabbar非常简单:

self.tabbarController = [[UITabbarController alloc] init]; [self.vIEw addSubvIEw:_tabbarController.vIEw];UIVIEwController * tab1 = [[UIVIEwController alloc] init];tab1.Title = "A";UIVIEwController * tab2 = [[UIVIEwController alloc] init];tab2.Title = "B";_tabbarController.vIEwControllers = [NSArray arrayWithObjects:patIEntSearch,todoList,nil];[tab1 release];[tab2 release];

您还可以轻松地将图像放入选项卡中:

tab1.tabbarItem.image = [UIImage imagenamed:@"myIcon.png"];

但是,如何将这些选项卡的图像设置为系统图像? (例如,搜索,收藏,书签等)在IB中,这是通过更改“标识符”来设置的,但是如何以编程方式执行此 *** 作

解决方法
UITabbarItem *aTabbarItem = [[UITabbarItem alloc] initWithTabbarSystemItem:UITabbarSystemItemFavorites tag:0];

UITabbarItem docs

UITabbarSystemItem
System items that can be used on a tab bar.

typedef enum {   UITabbarSystemItemmore,UITabbarSystemItemFavorites,UITabbarSystemItemFeatured,UITabbarSystemItemtopRated,UITabbarSystemItemRecents,UITabbarSystemItemContacts,UITabbarSystemItemHistory,UITabbarSystemItemBookmarks,UITabbarSystemItemSearch,UITabbarSystemItemDownloads,UITabbarSystemItemmostRecent,UITabbarSystemItemmostVIEwed,} UITabbarSystemItem;

设置为patIEntSearch.tabbarItem = aTabbarItem;

总结

以上是内存溢出为你收集整理的iphone – UITabBarController的程序创建和配置 – 为选项卡设置系统映像全部内容,希望文章能够帮你解决iphone – UITabBarController的程序创建和配置 – 为选项卡设置系统映像所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/web/1082594.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-27
下一篇2022-05-27

发表评论

登录后才能评论

评论列表(0条)

    保存