我正在嘗試更改導航欄後退按鈕文本的文本。我已經嘗試過這裏提供的解決方案,但我不能在後退按鈕上獲得我想要的文本。在我的appdelegate設置這些功能:導航欄後退按鈕文本不變
[[UINavigationBar appearance] setBarTintColor:[self colorWithHexString:@"e74c3c"]];
[[UINavigationBar appearance] setBarTintColor:[self colorWithHexString:@"e74c3c"]];
[[UINavigationBar appearance] setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor whiteColor], UITextAttributeTextColor,
[UIFont fontWithName:@"Futura-CondensedMedium" size:19.0], UITextAttributeFont,nil]];
NSShadow *shadow = [[NSShadow alloc] init];
shadow.shadowOffset = CGSizeMake(0.0, 1.0);
shadow.shadowColor = [UIColor whiteColor];
[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil]
setTitleTextAttributes:
@{NSForegroundColorAttributeName:[UIColor whiteColor],
NSShadowAttributeName:shadow,
NSFontAttributeName:[UIFont fontWithName:@"Futura-CondensedMedium" size:19.0]
}
forState:UIControlStateNormal];
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
,並在每個視圖 - 控制的viewdidload
我設置:
self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"SomeText" style:UIBarButtonItemStylePlain target:nil action:nil];
或
UIBarButtonItem *newBackButton =
[[UIBarButtonItem alloc] initWithTitle:@"NewTitle"
style:UIBarButtonItemStyleBordered
target:nil
action:nil];
[[self navigationItem] setBackBarButtonItem:newBackButton];
有什麼建議?
謝謝你。它的工作現在! – birdcage 2014-12-04 07:09:57