I am trying to create a UISlider with a track broken up into sections. Is it possible to break up the track and have each section be a different color? Rather than just min track and max track
Asked
Active
Viewed 945 times
-2
-
This can be achieved by checking the 2nd part of this answer https://stackoverflow.com/a/71575844/4833705. You can make the track colors of the slider, put the class from the answer behind/underneath it, then animate using the caLayer colors of your choice as it progresses – Lance Samaria Mar 23 '22 at 16:46
1 Answers
0
Is it possible to break up the track and have each section be a different color?
When you want to know what a built-in interface object will do, consult the documentation (e.g. https://developer.apple.com/documentation/uikit/uislider). You will readily learn that the built-in slider control itself can't do what you describe. But you can. For example, you could make a clear track and put the sectioned view behind it, or create your own slider control that draws the way you want it. There are lots of online explanations about how to write a customized version of a slider.

matt
- 515,959
- 87
- 875
- 1,141