user1302602
user1302602

Reputation: 419

IOS customized navigation back button is not working

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.

Upvotes: 2

Views: 1415

Answers (2)

The iOSDev
The iOSDev

Reputation: 5267

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 :)

Upvotes: 0

KPath001
KPath001

Reputation: 870

Try

[[UIBarButtonItem appearance] setBackButtonBackgroundImage:[UIImage imageNamed:@"someimage.png"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault].

Upvotes: 2

Related Questions