I’m trying to set image for my UIBarButtonItem and I can’t manage to do that. I tried two times, and in first case I get my image in right place, but when I click on button nothing happens (it should pop out a new window, but nothing works). There is the piece of code I have used:
UIImage *faceImage = [UIImage imageNamed:@"plus_button.png"];
UIButton *face = [UIButton buttonWithType:UIButtonTypeCustom];
face.bounds = CGRectMake( 0, 0, faceImage.size.width, faceImage.size.height );
[face setImage:faceImage forState:UIControlStateNormal];
UIBarButtonItem *faceBtn = [[[UIBarButtonItem alloc] initWithCustomView:face]initWithImage:faceImage style:UIBarButtonItemStylePlain target:self action:@selector(addProduct:)];
self.navigationItem.leftBarButtonItem = faceBtn;
In second case, I set image on button and new window appears as it should be, but there is not only my custom image I want, but also it show “borders”, it looks like image was put in center on default button. Obviously I want only my image, not borders, only my image. There is piece of code I have used in second case:
UIBarButtonItem *addButton = [[UIBarButtonItem alloc]initWithImage:faceImage style:UIBarStyleDefault target:self action:@selector(addProduct:)];
self.navigationItem.leftBarButtonItem = addButton;
Please help me to solve the problem, any help would be appreciated, thank you!
try this … change it’s method, image according to you