14

I am trying to change the Color of the Thumb on my UISlider - Somehow though, it always stays white. Changing the Color of the Bar itself seems to work quite well.

- (void)viewDidLoad
{
  [super viewDidLoad];
  // Do any additional setup after loading the view.
  self.redSlider.thumbTintColor = [UIColor redColor];
}

Am I missing something here?

I also found this Question here, that indicates it could be a bug - any idea?

Community
  • 1
  • 1
Martin Lang
  • 831
  • 11
  • 20

2 Answers2

8

Yes it's bug. To avoid without preparing dummy image use this code.

[s setThumbImage:s.currentThumbImage forState:UIControlStateNormal];
s.thumbTintColor = UIColor.redColor;
Alex Cio
  • 6,014
  • 5
  • 44
  • 74
Satachito
  • 5,838
  • 36
  • 43
  • 1
    Although this hack works, it changes the thumb image to have a 3D effect like the old iOS 6 style. iOS 7 should have a flat style. – Pwner Sep 04 '14 at 19:12
  • 1
    This approach isn't working in my scenario (within React Native). If I `setThumbImage` to an actual image in my `Images.xcassets` then it does work. Is there any alternative to `s.currentThumbImage`? – vitch Apr 23 '15 at 19:31
1

Did you set up anything about it in a xib/storyboard ?

If yes instead of change it into the viewDidLoad, try to set your color into

- (void)viewDidLayoutSubviews

If working, it's because this is called after loading values from storyboard, where viewDidLoad is called before.

Atheryl
  • 295
  • 4
  • 11