Can Poyrazoğlu Can Poyrazoğlu - 3 months ago 18
iOS Question

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

I have an app that runs perfectly on iOS 6. I've set a blinking effect to a UISlider's thumb this way:

-(void)startBlinkingSlider{
isSliderBlinking = YES;
isSliderTinted = NO;
[self performSelector:@selector(toggleSliderColor) withObject:nil afterDelay:0.2];
}

-(void)toggleSliderColor{
if(isSliderBlinking){
if(isSliderTinted){
self.effectAmountSlider.thumbTintColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:1];
}else{
self.effectAmountSlider.thumbTintColor = [UIColor colorWithRed:255 green:0 blue:0 alpha:1];
}
isSliderTinted = !isSliderTinted;
[self performSelector:@selector(toggleSliderColor) withObject:nil afterDelay:0.2];
}
}

-(void)stopBlinkingSlider{
isSliderBlinking = NO;
isSliderTinted = NO;
self.effectAmountSlider.thumbTintColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:1];
}


When I call
startBlinkingSlider
my slider starts blinking red in iOS 6. If I run the same exact app on my iOS 7 device, nothing happens. The slider's thumb retains its original white color. I've set a breakpoint on the line where I set the
thumbTintColor
. In debugger, here is what I'm getting:

(lldb) po self.effectAmountSlider.thumbTintColor
error: failed to get API lock
(lldb) po self.effectAmountSlider.thumbTintColor
UIDeviceRGBColorSpace 0 0 0 1
(lldb)


I typed the exact same code and got a weird message in the first one. However, the second result is correct. Then after setting it to red I'm also getting the correct result:

(lldb) po self.effectAmountSlider.thumbTintColor
UIDeviceRGBColorSpace 1 0 0 1


Even though the debugger shows the correct value, I'm getting no visual change in the slider. It's still white, color doesn't change in any way. I've searched Apple's documents here: https://developer.apple.com/library/ios/documentation/userexperience/conceptual/TransitionGuide/Controls.html

It doesn't say anything about UISlider's thumbTintColor not working as iOS 6. It should stay working as expected. I've checked the thread and everything is running on the main thread.
toggleSliderColor
is always on the main thread so it's not a threading issue. Why is my thumb color not working?

Thanks, Can.

Answer

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;