简体   繁体   English

适用于iOS6 +的带有图像的自定义后退按钮

[英]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. 我知道iOS7和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 您应该将leftBarBttonItem用于自定义后退按钮

 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;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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