[英]iOS 7 NavigationBar Back Button Custom Image with no Label
I am trying to create a custom back button on a navigation bar. 我正在尝试在导航栏上创建自定义后退按钮。 I start from the following:
我从以下内容开始:
// Nav bar - back button
[[UINavigationBar appearance] setTintColor:COLOR_WHITE];
[[UINavigationBar appearance] setBackIndicatorImage:[[UIImage imageNamed:@"navMenuBackButton"]
imageWithAlignmentRectInsets:UIEdgeInsetsMake(6.0, -6.0, 6.0, -6.0)]];
[[UINavigationBar appearance] setBackIndicatorTransitionMaskImage:[UIImage imageNamed:@"navMenuBackButton"]];
The image is 34x34 points so does not centre properly without the image alignment. 图像为34x34点,因此如果没有图像对齐,将无法正确居中。 The current problem is trying to get rid of the "Back" label without setting a blank title for each screen or making any changes on the ViewController itself.
当前的问题是试图摆脱“后退”标签,而无需为每个屏幕设置空白标题或对ViewController本身进行任何更改。
Any idea's? 有任何想法吗? Thank you
谢谢
Disable leftBarButtonItem and rightBarButtonItem. 禁用leftBarButtonItem和rightBarButtonItem。 Try the following.
请尝试以下方法。
[navigationItem.backItem.leftBarButtonItem setEnabled:NO];
[navigationItem.backItem.rightBarButtonItem setEnabled:NO];
[navigationItem.backItem setHidesBackButton:YES];
Did you try this : 您是否尝试过这个:
NSString *backString = @"";
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:backString
style:UIBarButtonItemStyleDone
target:nil
action:nil];
[[self navigationItem] setBackBarButtonItem:backButton];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.