Reputation: 3541
I use the following line to create a UIBarButtonItem with a custom icon named import2x.png:
UIBarButtonItem *btnImport = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"import2x.png"] style:UIBarButtonItemStylePlain target:self action:@selector(btnImport)];
The icon is a png that looks like this:
But here's how it looks when it is run on the simulator - a solid red square:
The icon is created using a transparent (alpha=0) background.
Any suggestions? TIA.
Upvotes: 3
Views: 6457
Reputation: 9330
The image in the link provided has an opaque background. If that is the same image you're using that's why it look's like a solid block.
It should be created with a transparent background, like this:
i.e. in Photoshop you should be able to see the background pattern like this:
Upvotes: 3
Reputation: 1490
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"g122.png"] style:UIBarButtonItemStylePlain target:self action:@selector(menuClieckd:)];
This worked for me
Upvotes: 2
Reputation: 4843
Try this one. Its working fine. I also share my output screenshot. u have to use small size of icon . but icon should be visible, no problem.
UIBarButtonItem *doneBtn = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"Login-pin.png"] landscapeImagePhone:[UIImage imageNamed:@"Login-pin.png"] style:UIBarButtonItemStylePlain target:self action:@selector(PickerCancelClick:)];
The search image is my output.
Upvotes: 2