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

后端 未结 4 1665
庸人自扰
庸人自扰 2021-01-08 01:41

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 = Y         


        
相关标签:
4条回答
  • 2021-01-08 01:50

    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.

    0 讨论(0)
  • 2021-01-08 01:53

    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)
    
    0 讨论(0)
  • 2021-01-08 01:57

    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.

    0 讨论(0)
  • 2021-01-08 02:11

    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;
    
    0 讨论(0)
提交回复
热议问题