UISlider setMaximumTrackTintColor [英] UISlider setMaximumTrackTintColor
问题描述
我正在尝试在UISlider上动态配置轨道颜色。
I'm trying to dynamically configure the track color on a UISlider.
这行代码非常适合设置滑块轨道的低端。
This line of code works perfectly for setting the low side of the slider track.
[self.sliderBar setMinimumTrackTintColor:[UIColor redColor]];
当尝试对滑块轨道的高端做同样的事情时,这行代码会向调试日志报告3个致命错误。
When trying to do the same thing for the high side of the slider track, this line of code reports 3 fatal errors to the debug log.
[self.sliderBar setMaximumTrackTintColor:[UIColor redColor]];
<Error>: CGContextAddPath: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
<Error>: clip: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
<Error>: CGContextDrawLinearGradient: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
我还尝试使用点表示法设置轨道色调颜色,但报告了相同的3个错误。
I have also tried to set the track tint colors using dot notation, but the same 3 errors were reported.
self.sliderBar.maximumTrackTintColor = [UIColor redColor];
我很困惑为什么最小轨道色调颜色被正确设置,而最大轨道色调颜色正在破碎。任何帮助将不胜感激。
I am very confused why the minimum track tint color is properly set, while the maximum track tint color is breaking. Any assistance would be greatly appreciated.
此问题似乎与这个问题,但我不是100%肯定,因为我不使用图形(只设置色调)。
This issue seems to be related to this question, but I'm not 100% sure since I'm not working with graphics (only setting the tint color).
推荐答案
这很奇怪,min和max对我来说都很好,我甚至可以让它变为动画颜色变化。我所能建议的是重新创建滑块和@synthesize。
That is strange, both min and max work fine for me and I can even have it animate color change. All I can suggest is re-create the slider and also @synthesize.
@synthesize slider;
- (void)viewDidLoad
{
[super viewDidLoad];
[slider setMinimumTrackTintColor:[UIColor orangeColor]];
[slider setMaximumTrackTintColor:[UIColor blueColor]];
// Do any additional setup after loading the view, typically from a nib.
}
这篇关于UISlider setMaximumTrackTintColor的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!