首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >UISlider setMaximumTrackTintColor

UISlider setMaximumTrackTintColor
EN

Stack Overflow用户
提问于 2014-02-11 00:59:02
回答 6查看 11.6K关注 0票数 14

我正在尝试在UISlider上动态配置轨道颜色。

这行代码可以完美地设置滑块轨道的低侧。

[self.sliderBar setMinimumTrackTintColor:[UIColor redColor]];

当尝试对滑块轨道的高边执行相同的操作时,该行代码在调试日志中报告了3个致命错误。

[self.sliderBar setMaximumTrackTintColor:[UIColor redColor]];

代码语言:javascript
复制
<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%确定,因为我不是在处理图形(只设置色调颜色)。

EN

回答 6

Stack Overflow用户

发布于 2014-02-11 05:35:25

这很奇怪,min和max对我来说都很好,我甚至可以让它动态地改变颜色。我所能建议的就是重新创建滑块和@synthesize。

代码语言:javascript
复制
@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.
}

票数 19
EN

Stack Overflow用户

发布于 2015-04-17 02:11:29

避免冗余地设置maximumTrackTintColor。当我的代码更新颜色两次时,最大线条就会消失。我可以用一个简单的UISlider重现它,如下所示:

代码语言:javascript
复制
    UISlider *slider = [[UISlider alloc] initWithFrame:CGRectMake(0, 0, 150, 23)];
    slider.maximumTrackTintColor = [UIColor whiteColor];
    slider.maximumTrackTintColor = [UIColor whiteColor];

在iOS 8下显示在屏幕上时,此滑块将没有最大轨迹,而不是白色轨迹。

票数 7
EN

Stack Overflow用户

发布于 2015-02-13 01:11:03

这是一个苹果的bug,它仍然存在于iOS 8中。当我试图通过一个子类上的代理设置器来修改滑块的最大色调颜色时,我看到过它。更改最小色调颜色可以很好地工作,并且不会显示错误,但尝试更改最大色调颜色会抛出大量糟糕的上下文错误,并且经常在错误的位置绘制滑块渐变的那部分(这证明它确实没有良好的上下文)。

我找不到解决这个问题的办法,但我会提交一个错误报告。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21683348

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档