UISlider thumbTintColor doesn't change on iOS 7 (fine on iOS 6)

梦想的初衷 提交于 2019-12-01 02:41:15

On basis of @aaronsti's answer I found that the following worked for me. Setting thumb-image to nil had no effect.

  [_slider setThumbImage:[_slider thumbImageForState:UIControlStateNormal] forState:UIControlStateNormal];
_slider.minimumTrackTintColor = minTintColor;
_slider.thumbTintColor = thumbTintColor;
aaronsti

I discovered a workaround. By first calling the 'setThumbImage:forState:' method, the 'thumbTintColor' property will then take effect.

[self.slider setThumbImage:[UIImage imageNamed:@"Thumb.png"] 
                  forState:UIControlStateNormal];
self.slider.thumbTintColor = [UIColor blackColor];

I tested this on Version 7.0 (463.9.4.2) of iOS Simulator.

I just so happened to read the iOS 7 UI Transition Guide again this morning, and tripped on a statement under Slider. If EITHER maximumTrackTineColor OR thumbTintColor are nil, then both properties are ignored. So I tried to set all the tint colors, thumb still white.

I entered a bug report on this - #15277127 - reference it if you enter your own bug. The more bug reports the more likely Apple will fix it soon.

EDIT: Apple duped my bug to another one - this was obviously known a while ago.

So far in Xcode 6.2, iOS 8.2 the problem is still there, and the workaround still works. Swift version:

slider.setThumbImage(slider.thumbImageForState(.Normal), forState:.Normal)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!