Luk*_*ice 6 iphone cocoa-touch objective-c ipad ios
以编程方式在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];
Run Code Online (Sandbox Code Playgroud)
您还可以轻松地将图像放入选项卡中:
tab1.tabBarItem.image = [UIImage imageNamed:@"myIcon.png"];
Run Code Online (Sandbox Code Playgroud)
但是,如何将这些选项卡的图像设置为系统图像?(例如,搜索,收藏,书签等)在IB中,这是通过更改"标识符"来设置的,但是如何以编程方式执行此操作
Ale*_*nte 11
UITabBarItem *aTabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemFavorites tag:0];
Run Code Online (Sandbox Code Playgroud)
UITabBarItem docs
UITabBarSystemItem可以在选项卡栏上使用的系统项.
typedef enum {
UITabBarSystemItemMore,
UITabBarSystemItemFavorites,
UITabBarSystemItemFeatured,
UITabBarSystemItemTopRated,
UITabBarSystemItemRecents,
UITabBarSystemItemContacts,
UITabBarSystemItemHistory,
UITabBarSystemItemBookmarks,
UITabBarSystemItemSearch,
UITabBarSystemItemDownloads,
UITabBarSystemItemMostRecent,
UITabBarSystemItemMostViewed,
} UITabBarSystemItem;
Run Code Online (Sandbox Code Playgroud)
设置它 patientSearch.tabBarItem = aTabBarItem;
| 归档时间: |
|
| 查看次数: |
2044 次 |
| 最近记录: |