mkk
mkk

Reputation: 675

Building custom ios control based on elements of native controls

I would like to create range slider control (slider with two handles, one for lower bound, one for upper bound). Is there a way to extract from UITextView control text selection handles, to make my range slider look the same as text selection? I would like to use at least the same graphics/layout without hard copying it to my project.

Upvotes: 0

Views: 64

Answers (2)

Julian F. Weinert
Julian F. Weinert

Reputation: 7560

You may create a subclass of UIControl and implement everything there. You should find good articles on how UIControl subclasses are working.

Then you implement two UIViews, one for the left, one for the right button. You need to do the tracking (of movement) completely yourself, but this is pretty straight forward.

To achieve the look of the text selection control, you can use iOS-Artwork-Extractor to get your hands on the systems assets, but I highly recommend not steeling Apples property to then submit it back to them ;-)

You can simply follow this tutorial (OMG, look at their example)

EDIT appendix

Me and @JanGreve agreed on strongly discouraging from using the UITextView selection controls (in terms of assets) for another reason: People are familiar with these controls being used for a specific functionality.

If you provide different UX, as you clearly want to, please use different knobs. The ones of UISlider would be more suitable.

Upvotes: 2

Tobi Nary
Tobi Nary

Reputation: 4596

No. Also, that would not be advisable, because different kinds of data should have different UI Elements representing that. Text selection is not a slider for a range as such. At least, from an UX perspective.

Upvotes: 2

Related Questions