UIBarbutton图像颜色不显示

时间:2010-12-22 10:44:20

标签: iphone

我创建了UITools并添加了UIbarbuttonitem init,我将图像添加到UIBarbutton。但图像显示为黑色和白色。

如何更改我的图像原始颜色。

我的代码是:

UIToolbar *tools1 = [[[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 70, 44.5)]autorelease];
NSMutableArray* buttons1 = [[NSMutableArray alloc] initWithCapacity:2];
    UIBarButtonItem* bi1 = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"searchicon.png"] style:UIBarButtonItemStylePlain target:self action:@selector(search:)];
    [buttons1 addObject:bi1];
    [bi1 release];
bi1 = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"Star.png"] style:UIBarButtonItemStylePlain target:self action:@selector(ShowFav:)];
[buttons1 addObject:bi1];
[bi1 release];
[tools1 setItems:buttons1 animated:NO];
[buttons1 release];
tools1.tintColor=[UIColor blackColor];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:tools1];
    [tools1 release];

1 个答案:

答案 0 :(得分:3)

UIButtonBar图像始终显示为灰度(系统应用蓝色色调),源图像中的alpha级别用于确定选定和未选择的图像。

如果您想创建自己的自定义标签栏,其中包含完整的colo(u)r图标等,可以使用以下几个方法:Custom colors in UITabBar