我无法使用情节提要提供 UItabbar 项目的彩色图像。请帮助我。提前谢谢。
问问题
104 次
3 回答
1
只需添加CustomTabbarController
您的项目并设置您的 TabBarController 类CustomTabbarController
,这将为您工作。
#import "CustomTabbarController.h"
#import "FirstViewController.h"
#import "SecondViewController.h"
#import "ThirdViewController.h"
@implementation CustomTabbarController
- (void)viewDidLoad
{
[super viewDidLoad];
FirstViewController *first = [[FirstViewController alloc]init];
SecondViewController *second = [[SecondViewController alloc]init];
ThirdViewController *third = [[ThirdViewController alloc]init];
[self setViewControllers:[NSArray arrayWithObjects:first, second, third, nil]];
UIImage *selectedImage0 = [UIImage imageNamed:@"home-active.png"];
UIImage *unselectedImage0 = [UIImage imageNamed:@"home.png"];
UIImage *selectedImage1 = [UIImage imageNamed:@"star-active.png"];
UIImage *unselectedImage1 = [UIImage imageNamed:@"star.png"];
UIImage *selectedImage2 = [UIImage imageNamed:@"search-active.png"];
UIImage *unselectedImage2 = [UIImage imageNamed:@"search.png"];
UITabBar *tabBar = self.tabBar;
UITabBarItem *item0 = [tabBar.items objectAtIndex:0];
UITabBarItem *item1 = [tabBar.items objectAtIndex:1];
UITabBarItem *item2 = [tabBar.items objectAtIndex:2];
[item0 setFinishedSelectedImage:selectedImage0 withFinishedUnselectedImage:unselectedImage0];
[item1 setFinishedSelectedImage:selectedImage1 withFinishedUnselectedImage:unselectedImage1];
[item2 setFinishedSelectedImage:selectedImage2 withFinishedUnselectedImage:unselectedImage2];
}
@end
于 2013-01-29T07:21:35.920 回答
0
您需要为此创建自定义标签栏。
希望对您有所帮助。
干杯!
于 2013-01-29T06:44:33.310 回答
-1
是的,你不能在情节提要中做到这一点。
现在情节提要仅支持图标类型的色调图像。
但是您可以通过代码设置您想要设置的任何图像。
如果您对代码没有想法并且需要一些帮助而不是评论,我可能会提供帮助。
于 2013-01-29T06:49:48.183 回答