gpt4 book ai didi

ios - 在 ios6 中更改导航栏按钮项目颜色

转载 作者:行者123 更新时间:2023-11-29 02:47:51 24 4
gpt4 key购买 nike

我想为iOS6改变导航栏后退按钮的颜色,我尽力了但没有成功。那么请问有人能帮我找到完美的解决方案吗?

我想让这个按钮的背景变黑。

我用过

[[UIBarButtonItem appearance]setTintColor:[UIColor blackColor]];

但它不起作用。我也用过这个:

[[[self navigationController] navigationBar] setBarTintColor:[UIColor blackColor]]; 

但出现此错误:

Terminating app due to uncaught exception
NSInvalidArgumentException', reason: '-[UINavigationBar setBarTintColor:]: unrecognized selector sent to instance 0x9d2ab30

最佳答案

iOS 6

[[UINavigationBar appearance] setTintColor:[UIColor blackColor]];

在 ios7 中

[[UINavigationBar appearance] setBarTintColor:[UIColor blackColor]];

另一种选择

//allocating the bar button
UIBarButtonItem *leftBarButton = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStyleBordered target:self action:@selector(popToBack)];

//assign the bar button to the navigation bar

self.navigationItem.leftBarButtonItem = leftBarButton;

//change the tint color of the bar button item
self.navigationItem.leftBarButtonItem.tintColor=[UIColor colorWithRed:125.0/255.0 green:90.0/255.0 blue:146.0/255.0 alpha:1]; //[UIColor blackColor]


-(void)popToBack
{
[self.navigationController popViewControllerAnimated:YES];
}

关于ios - 在 ios6 中更改导航栏按钮项目颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24883731/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com