Search code examples
iphoneobjective-cioscocoa-touch

iPhone App: How to implement horizontal knob as shown in image


I want to implement horizontal knob where user can set the value moving the knob

enter image description here

enter image description here

Here as shown image how to set the distance value from picker (horizontal nob)?

How can I achieve that?


Solution

  • I would use an UIPickerView modified with CGAffineTransform - to scale it and rotate it by 90 degrees. That you would get the notifications on what component the user did select, by implementing the standard UIPickerDelegate methods.

    You'd need to supply the labels by using the

    - (UIView *)viewForRow:(NSInteger)row forComponent:(NSInteger)component
    

    method, and rotate them by -90 degrees to appear correctly aligned - also, the transformation applied to the picker could distort the views too, so you'd may have to upscale them.

    It would take some trial and error to make it look perfect, but it seems easily doable. And I think that's what they used in the example you provided.