2

I tried the following in my view controller. Didn't work. I am using Storyboard.

[super viewDidLoad];

UIImage *backImage = [UIImage imageNamed:@"Back.png"] ;
UIBarButtonItem *backButton=[[UIBarButtonItem alloc]initWithImage:backImage style:     (UIBarButtonItemStyleBordered) target:nil action:nil];
backButton.title=@"TEST";
[self.navigationItem setBackBarButtonItem:backButton];

Please help. Thanks.

3
  • what do you mean...please elaborate Commented Jul 11, 2012 at 23:05
  • does this work [[UIBarButtonItem appearance] setBackButtonBackgroundImage:[UIImage imageNamed:@"someimage.png"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault]. Commented Jul 11, 2012 at 23:07
  • or did you want something else out of it Commented Jul 11, 2012 at 23:07

2 Answers 2

2

Try

[[UIBarButtonItem appearance] setBackButtonBackgroundImage:[UIImage imageNamed:@"someimage.png"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault].
Sign up to request clarification or add additional context in comments.

2 Comments

this works but the images are too big...what should i do to the image?
the images wouldn't click to the button.
0

try this one this will solve your image problem

UIImage *backImage = [[UIImage imageNamed:@"Back.png"]resizableImageWithCapInsets:UIEdgeInsetsMake(0, 5, 0, 5)];

[[UIBarButtonItem appearance] setBackButtonBackgroundImage:backImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];

May this will solve your problem.

Happy Coding :)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.