好吧,我有一个不同颜色的NavigationController,我希望后退按钮也有背景图像,突出显示的背景图像和自定义文本颜色。我怎样才能做到这一点?我已经尝试了很多东西,但我还没有能够改变这个后退按钮。
答案 0 :(得分:1)
我想你必须创建自己的自定义按钮。
你只能指向leftBarButtonItem,因为backBarButtonItem是ReadOnly。
self.navigationItem.leftBarButtonItem = aCustomBarButtonItem;
self.navigationItem.hidesBackButton = YES;
希望这会有所帮助......
修改强>
可以提供帮助的代码:
UIButton *aCustomButton = [UIButton buttonWithType:UIButtonTypeCustom];
[aCustomButton setBackgroundImage:[UIImage imageNamed:@"back1.png"] forState:UIControlStateNormal];
[aCustomButton setBackgroundImage:[UIImage imageNamed:@"back2.png"] forState:UIControlStateHighlighted];
[aCustomButton addTarget:self action:@selector(onClickOfBack) forControlEvents:UIControlEventTouchUpInside];
[aCustomButton setFrame:CGRectMake(0, 0, 50, 40)];
UIBarButtonItem *aCustomBarButton = [[UIBarButtonItem alloc] initWithCustomView:aCustomButton];
self.navigationItem.leftBarButtonItem = aCustomBarButton;
[aCustomBarButton release];