Question

I'm trying to have a custom back button with image only (no text).

I'm aware that there could be slightly ifferent solution for iOS7 and iOS6. For now I'm not successfull with any.

All I achieved was this:

enter image description here

White default arrow is still there :(

I used this code:

    UIImage *temp = [[UIImage imageNamed:@"button_back.png"] imageWithRenderingMode: UIImageRenderingModeAlwaysOriginal];
    UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithImage:temp style:UIBarButtonItemStyleBordered target:self action:@selector(action)];
    [[self navigationItem] setBackBarButtonItem:backButton];
Était-ce utile?

La solution

You should use leftBarBttonItem for custom back button

 UIImage *temp = [[UIImage imageNamed:@"button_back.png"] imageWithRenderingMode: UIImageRenderingModeAlwaysOriginal];
 UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithImage:temp style:UIBarButtonItemStyleBordered target:self action:@selector(action)];
 self navigationItem.leftBarButtonItem = backButton;
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top