1
votes

I'm trying to create a UISlider with a custom thumb image. This works fine, but does not work if I disable the slider. Here's my code:

UISlider *slider = [[UISlider alloc]initWithFrame:CGRectMake(130, 10, sliderBG.size.width, sliderBG.size.height)];
slider.enabled = NO;
[slider setThumbImage:thumbCircle forState:UIControlStateHighlighted];

2 questions:

1) It's using the right image when I set state for UIControlStateHighlighted, but not when I set state to UIControlStateDisabled. Why?

2) The thumb image looks transparent. My image is not transparent. Is the UISlider doing this? Any way to get around it?

Thanks!

2

2 Answers

0
votes

That is how UISlider work: use a transparent knob to indicate inactivity. If you want one that does not do that, try recreate it yourself using several UIImageView's and following a finger isn't that difficult on iOS.

0
votes

Try adding:

[slider setThumbImage:thumbCircle forState: UIControlStateDisabled ];