如何更改默认backBarButtonItem上的颜色/图像? [英] How do you change color/image on the default backBarButtonItem?
问题描述
我需要在默认的self.navigationItem.backBarButtonItem上更改颜色。为了实现这一点,我创建了一个自定义Button类并实现如下:
I need to change color on the default "self.navigationItem.backBarButtonItem". To accomplish this I´ve created an custom Button class and implemented it like this:
- (void)viewDidLoad {
[super viewDidLoad];
BackButton *blueSaveButton = [[BackButton alloc] init];
UIBarButtonItem *temporaryBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:blueSaveButton];
temporaryBarButtonItem.title = @"Tillbaka";
self.navigationItem.backBarButtonItem = temporaryBarButtonItem;
[temporaryBarButtonItem release];
[blueSaveButton release];
[self gotoLocation];
}
但这没有效果完全按下按钮。
那你怎么设法做到这一点而不破坏导航栏的默认/继承行为?
But this has no effect at all on the button. So how do you manage to do this without "breaking" the default/inherited behavior of the navigationbar?
编辑:原因是按钮需要是公司品牌,所以默认样式不会。
The reason is that the button needs to be corporate branded, so default styles will not do.
BR
推荐答案
<好的,找到了解决方案(不太好但是有效)这样做:
1:实现本教程中的按钮: www.switchonthecode.com
这将覆盖导航栏的默认行为。
This will override the default behavior of navigationbar.
2:在需要自定义按钮的每个视图中实现此功能:
osmorphis.blogspot.com
2: Implement this in every view that needs the custom button: osmorphis.blogspot.com
BR
这篇关于如何更改默认backBarButtonItem上的颜色/图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!