Search code examples
ioscocoarangeuislider

Select a range in UISlider


i asked me whether it is possible if i can create a uislider who has 2 handles to select a range. Just like here:

enter image description here

The problem i am facing is that i dont want to use a custom UIControl Subclass. I need a UISlider subclass or a other solution for this problem, because a lot of the code is based on UISlider specific propertys etc. So is there any possibility to achieve this ?


Solution

  • You can subclass UISlider, but it will be very difficult. Your class should offer quite some new properties, and the old ones won't make much sense at all.

    Not sure how your code can be based much on UISlider specific things - as everything would change the meaning (i.e. ranges instead of one value).

    If you really need a common base class, you could encapsulate ("has-a" relationship) the control in a custom class and let this handle the different types.

    I implemented a similar control using a custom view, and it happened to be quite straight forward.