我试图在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,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,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%肯定,因为我不使用图形(只设置色调的颜色).
解决方法
这是奇怪的,最小和最大的工作对我来说很好,我甚至可以有它的动画颜色变化.我可以建议的是重新创建滑块和@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. }