0

I created UITools and add UIbarbuttonitem init and I add images to UIBarbutton. But images are dispalyed as Black and white.

How to change my image original color.

My code is:

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];
halfer
  • 19,824
  • 17
  • 99
  • 186
Velmurugan
  • 2,303
  • 6
  • 30
  • 45

1 Answers1

3

UIButtonBar images are always displayed as greyscale (with the system applied blue tint), with the alpha level in the source image used to determine the selected and un-selected images.

If you want to create your own custom tab bar with full colo(u)r icons, etc. there are a few approaches, as discussed in this question: Custom colors in UITabBar

Community
  • 1
  • 1
John Parker
  • 54,048
  • 11
  • 129
  • 129