2010-12-22 71 views
0

我创建了UITools并添加了UIbarbuttonitem init并将图像添加到了UIBarbutton。但图像显示为黑色和白色。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]; 

回答

3

UIButtonBar图像总是显示为灰度(与系统应用蓝色调),与用于确定所选择的和未选择的图像的源图像中的α水平。

如果你想创建拥有完全科洛(U)R图标等也有一些办法,因为在这个问题上讨论自己的自定义标签栏:Custom colors in UITabBar