gpt4 book ai didi

ios - 在 iOS 中为 UINavigationBar 着色

转载 作者:行者123 更新时间:2023-11-29 05:08:08 25 4
gpt4 key购买 nike

我将导航栏着色为橙色:

navigationController.navigationBar.tintColor = [UIColor colorWithRed:0.88 green:0.52 blue:0.27 alpha:1];

一切正常,每个按钮都像条一样橙色,但是当 ic 进入自定义右侧项目菜单时,它显示为蓝色。这是屏幕截图:http://img146.imageshack.us/img146/5605/schermata20091202a14565.png

这是右侧按钮的代码:

UIView *container = [[UIView alloc] init];
UIToolbar *tools = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 80, 45)];

NSMutableArray *buttons = [[NSMutableArray alloc] initWithCapacity:2];

UIBarButtonItem *bi = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addGadget:)];
bi.style = UIBarButtonItemStyleBordered;
[buttons addObject:bi];
[bi release];

bi = [[UIBarButtonItem alloc]
initWithImage:[UIImage imageNamed:@"less.png"] style:UIBarButtonItemStyleBordered target:self action:@selector(setEditing:)];
[buttons addObject:bi];
[bi release];

[tools setItems:buttons animated:NO];
[buttons release];

self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:tools];
[tools release];

如何让一切都变成橙色?

最佳答案

您应该将 UIToolbar 对象的 tintColor 设置为与 UINavigationBar 的相同。

请注意,UIToolbarUINavigationBar 不同,背景渐变/颜色有点不同。尝试将 UIToolbar 的背景颜色设置为 +[UIColor clearColor]

此外,您可能甚至不需要容器 UIView,因为 UIToolbarUIView 的子类,因此您可以使用它作为 customView 本身。

关于ios - 在 iOS 中为 UINavigationBar 着色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1833080/

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