UIButton颜色变化

3

我正在制作一个“信息”按钮,使用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个不同视图控制器的滚动视图。一个蓝色的,一个红色的,一个绿色的。
图标在应用程序打开的页面上看起来很好(蓝色):
但是,当我滑动到绿色或红色页面时,按钮似乎保持蓝色,而不是像我想要的那样透明:
我该如何阻止它这样做?我只想让图标是透明的。
1个回答

13

UIButtonTypeInfoLight 使用应用程序的着色颜色,该颜色默认为蓝色。您可以在运行时更改 UIButton 的着色颜色:

[infoButton setTintColor:[UIColor redColor]];

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接