gpt4 book ai didi

ios - UIButton 颜色变化

转载 作者:可可西里 更新时间:2023-11-01 06:19:40 26 4
gpt4 key购买 nike

我正在制作一个“信息”按钮,使用 Xcode 的内置按钮类型“UIButtonTypeInfoLight”。

这是我的代码:

self.helpButton= [UIButton buttonWithType:UIButtonTypeInfoLight];
[self.helpButton addTarget:self
action:@selector(showHelp)
forControlEvents:UIControlEventTouchUpInside];
self.helpButton.frame = CGRectMake(280.0, 440.0, 20, 20);
[self.view addSubview:self.helpButton];

但是,有一个问题。我的应用程序包含一个带有 3 个不同 View Controller 的 ScrollView 。一蓝一红一绿。

图标在应用程序打开的页面上看起来不错(蓝色):

enter image description here

但是,当我滑动到绿色或红色页面时,按钮似乎保持蓝色,并且不像我希望的那样透明:

enter image description here enter image description here

我怎样才能阻止它这样做?我只想让图标透明?

最佳答案

UIButtonTypeInfoLight 使用应用程序的色调颜色,默认为您看到的蓝色。您可以做的是即时更改 UIButton 的色调:

[infoButton setTintColor:[UIColor redColor]];

关于ios - UIButton 颜色变化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20505867/

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