我正在尝试更改导航栏中后退按钮的箭头颜色。我已经能够改变文本颜色,但不能改变箭头。这是我更改文本颜色的代码:
[[UIBarButtonItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor whiteColor], UITextAttributeTextColor,
nil] forState:UIControlStateNormal];
如果有人可以告诉我如何更换大肠杆菌,那将非常有帮助!
答案 0 :(得分:2)
您可以使用这样的图像来更改后退按钮的背景:
UIImage *buttonBack30 = [[UIImage imageNamed:@"button_back_textured_30"]
resizableImageWithCapInsets:UIEdgeInsetsMake(0, 13, 0, 5)];
UIImage *buttonBack24 = [[UIImage imageNamed:@"button_back_textured_24"]
resizableImageWithCapInsets:UIEdgeInsetsMake(0, 12, 0, 5)];
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:buttonBack30
forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:buttonBack24
forState:UIControlStateNormal barMetrics:UIBarMetricsLandscapePhone];
如果您不想使用图像,可以更改导航栏的tintcolor,因为它决定了bar按钮项目文本的颜色:
[[UINavigationBar appearance] setTintColor:[UIColor yourColor]];