I've created a slider track that is draw on the actual background of my app and I've also drawn the UISlider thumb image. I know how to set the thumb image for the slider. But how do I hide the UISlider track?
Asked
Active
Viewed 8,757 times
7
-
possible duplicate of [How to make UISlider's "track" invisible?](http://stackoverflow.com/questions/4150903/how-to-make-uisliders-track-invisible) – OrangeDog Aug 18 '15 at 12:44
4 Answers
24
If you do not want to use transparent images, you can just set the track images to empty UIImage objects:
[slider setMinimumTrackImage:[UIImage alloc] forState:UIControlStateNormal];
[slider setMaximumTrackImage:[UIImage alloc] forState:UIControlStateNormal];

Avario
- 4,655
- 3
- 26
- 19
-
I realize this is a separate question, but are there any potential repercussions from not calling init on those images? – livingtech Jun 06 '13 at 19:39
-
1There should be no repercussions of not using init. The init method usually just sets default properties of an object, which are not required for UIImage. However, using [[UIImage alloc] init] or [UIImage new] will have the same effect in this case. – Avario Jun 07 '13 at 01:24
9
Use a 1px transparent image for the min and max track images. I answered this very same question yesterday.
0
Easy One :
[_slider setThumbImage:[UIImage new] forState:UIControlStateNormal];

itsji10dra
- 4,603
- 3
- 39
- 59