Reputation: 41470
How do I make navigation bar button item show my custom image as is? Using the code below my button shows up as a solid color. The outline of the image shows up correctly.
UIImage *image = [UIImage imageNamed:@"image.png"];
UIBarButtonItem *buttonItem = [[UIBarButtonItem alloc] initWithImage:image style:UIBarButtonItemStylePlain target:self action:@selector(onButtonTapped:)];
self.navigationItem.leftBarButtonItem = buttonItem;
Upvotes: 1
Views: 359
Reputation: 4218
If you are on iOS7 try to change the UIImage's rendering mode
UIImage *image = [UIImage imageNamed:@"image.png"];
UIImage *newImage = [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
use newImage to init the bar button item
Upvotes: 3