gpt4 book ai didi

ios - 为 Bar button item 添加 Bg 和 tint color

转载 作者:行者123 更新时间:2023-11-28 19:40:41 24 4
gpt4 key购买 nike

我以编程方式创建了一个条形按钮项。现在它看起来是简单的文本。我需要设置无边框的背景颜色,还需要以编程方式设置色调颜色。这是我创建一个条形按钮项目的代码:

UIBarButtonItem *callBtn = [[UIBarButtonItem alloc] initWithTitle:@"Call Me" style:UIBarButtonItemStylePlain target:self action:@selector(signUpButtonTapped:)];
self.navigationItem.rightBarButtonItem = callBtn;

背景颜色应该是:#F9F9F9

色调颜色应为:00ACC1

请帮我做

我需要这样的图片:

enter image description here

最佳答案

使用自定义按钮进行自定义控制以下代码可能会有所帮助

 UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
button.frame = CGRectMake(0,0,60,30);
[button setBackgroundColor:[UIColor yourColor]];
[button setTitleColor:[UIColor yourColor] forState:UIControlStateNormal];
[button setTitle:@"Call Me" forState:UIControlStateNormal];
[button addTarget:self action:@selector(navigateToDiscussionScreen) forControlEvents:UIControlEventTouchUpInside];

UIView *view = [[UIView alloc] initWithFrame:button.bounds];
view.backgroundColor = [UIColor clearColor];
[view addSubview:button];
UIBarButtonItem *logoBtn = [[UIBarButtonItem alloc]initWithCustomView:view];

关于ios - 为 Bar button item 添加 Bg 和 tint color,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34546319/

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