2010-12-22 70 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