UIButton颜色变化
问题描述:
我正在使用Xcode的内置按钮类型“UIButtonTypeInfoLight”制作'info'按钮。UIButton颜色变化
这是我的代码:
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个不同视图控制器的滚动视图。一个蓝色,一个红色和一个绿色。
的图标看起来该应用打开了(蓝色)在页面上罚款:
然而,当我刷到绿色或红色的页面,该按钮似乎停留蓝,没有透明的像我希望它是:
我怎么能阻止它这样做呢?我只想让图标透明?
答
UIButtonTypeInfoLight使用应用程序的tint颜色,默认为您看到的蓝色。你可以做的是在飞行中改变UIButton的色调颜色:
[infoButton setTintColor:[UIColor redColor]];