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
source to share
3 answers
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
source to share