UIBarButtonItem custom icon
I am using 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 this is what it looks like when it runs on the simulator - a solid red square:
The icon is created using a transparent (alpha = 0) background.
Any suggestions? TIA.
+3
RegularExpression
source
to share
3 answers
The image in the provided link has an opaque background. If it's the same image, you're using why it looks like a solid block.
It should be created with a transparent background, for example:
i.e. in Photoshop, you should see a background image like this:
+2
Craig
source
to share
Try it. His work is wonderful. I am also sharing my screenshot. u should use small icon size. but the 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 conclusion.
+2
SR Nayak
source
to share
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"g122.png"] style:UIBarButtonItemStylePlain target:self action:@selector(menuClieckd:)];
This worked for me
+2
Parth pandya
source
to share