简体   繁体   中英

Custom Back button with image for iOS6+

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:

在此处输入图片说明

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];

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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM