1

我是ios新手。我想在标签栏中制作应用程序

现在,此屏幕截图中的标签栏颜色。



我在 iphone 中想要的 UI 是这张图片

在标签栏的每个图标中,我使用了黑色图像

提前致谢

4

2 回答 2

0

您必须UITabBarItems使用以下内容分别设置每个:

UITabBarItem *tabBarItem1 = [[UITabBarItem alloc] initWithTitle:@"Title1" image:[UIImage imageNamed:@"image1.png"] tag:1];
[tabBarItem1 setFinishedSelectedImage:nil withFinishedUnselectedImage:[UIImage imageNamed:@"image1.png"]];
[[myTabBarController.viewControllers objectAtIndex:0] setTabBarItem:tabBarItem1];

对于您的每个视图控制器。

于 2013-02-04T15:07:25.520 回答
0

didFinishLaunchingWithOptions应用程序委托的方法中,您需要添加一些这样的代码。

//Get the Tab Bar
UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
tabBarController.delegate = self;
UITabBar *tabBar = tabBarController.tabBar;

//You may want to set the background of the tab bar (optional)
[tabBar setBackgroundImage:[UIImage imageNamed:@"CustomTabBar.png"]];

//You will need to repeat this code for each tab bar item
UITabBarItem *tabBarItem3 = [tabBar.items objectAtIndex:2];
tabBarItem3.title = @"Settings";
tabBarItem3.image = nil;
[tabBarItem3 setFinishedSelectedImage:[UIImage imageNamed:@"settings-button-selected.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"settings-button.png"]];

不要忘记为视网膜支持制作@2x 图像。

您还可以更改每个 tabBarItem 的其他设置 - 查看文档以了解更多信息。

于 2013-02-04T15:12:04.410 回答