我正在尝试在UISlider上动态配置轨道颜色。
这行代码可以完美地设置滑块轨道的低侧。
[self.sliderBar setMinimumTrackTintColor:[UIColor redColor]];
当尝试对滑块轨道的高边执行相同的操作时,该行代码在调试日志中报告了3个致命错误。
[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个错误。
self.sliderBar.maximumTrackTintColor = [UIColor redColor];
我非常困惑为什么最小轨道色调颜色被正确设置,而最大轨道色调颜色却被破坏。任何帮助都将不胜感激。
这个问题似乎与this问题有关,但我不能100%确定,因为我不是在处理图形(只设置色调颜色)。
发布于 2014-02-11 05:35:25
这很奇怪,min和max对我来说都很好,我甚至可以让它动态地改变颜色。我所能建议的就是重新创建滑块和@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.
}

发布于 2015-04-17 02:11:29
避免冗余地设置maximumTrackTintColor。当我的代码更新颜色两次时,最大线条就会消失。我可以用一个简单的UISlider重现它,如下所示:
UISlider *slider = [[UISlider alloc] initWithFrame:CGRectMake(0, 0, 150, 23)];
slider.maximumTrackTintColor = [UIColor whiteColor];
slider.maximumTrackTintColor = [UIColor whiteColor];在iOS 8下显示在屏幕上时,此滑块将没有最大轨迹,而不是白色轨迹。
发布于 2015-02-13 01:11:03
这是一个苹果的bug,它仍然存在于iOS 8中。当我试图通过一个子类上的代理设置器来修改滑块的最大色调颜色时,我看到过它。更改最小色调颜色可以很好地工作,并且不会显示错误,但尝试更改最大色调颜色会抛出大量糟糕的上下文错误,并且经常在错误的位置绘制滑块渐变的那部分(这证明它确实没有良好的上下文)。
我找不到解决这个问题的办法,但我会提交一个错误报告。
https://stackoverflow.com/questions/21683348
复制相似问题