Rei*_*eid 13 objective-c uislider ios ios7
我正在尝试在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.
Run Code Online (Sandbox Code Playgroud)
我还尝试使用点表示法设置轨道色调颜色,但报告了相同的3个错误.
self.sliderBar.maximumTrackTintColor = [UIColor redColor];
我很困惑为什么最小轨道色调颜色被正确设置,而最大轨道色调颜色正在破碎.任何帮助将不胜感激.
这个问题似乎与这个问题有关,但我不是100%肯定,因为我不使用图形(只设置色调).
Ahu*_*ord 19
这很奇怪,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.
}
Run Code Online (Sandbox Code Playgroud)
避免冗余地设置maximumTrackTintColor.当我的代码两次更新颜色时,最大行将消失.我能用一个简单的UISlider重现它,如下所示:
UISlider *slider = [[UISlider alloc] initWithFrame:CGRectMake(0, 0, 150, 23)];
slider.maximumTrackTintColor = [UIColor whiteColor];
slider.maximumTrackTintColor = [UIColor whiteColor];
Run Code Online (Sandbox Code Playgroud)
在iOS 8下的屏幕上显示时,此滑块将没有最大轨道,而不是白色轨道.
归档时间: |
|
查看次数: |
10373 次 |
最近记录: |