我无法使用故事板提供彩色的UItabbar项目图片。请提前帮助我。谢谢。
答案 0 :(得分: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
答案 1 :(得分:0)
您需要为此创建自定义标签栏。
希望它对你有所帮助。
干杯!
答案 2 :(得分:-1)
是的,你不能在故事板中这样做。
现在,故事板只支持图标类型的色调图像。
但您可以设置要通过代码设置的任何图像。
如果您不了解代码并希望得到一些帮助而不是评论我可能会帮助。