Search code examples
iosobjective-ccocoa-touchcolorscolor-picker

Custom color picker for iOS


I was looking for a color picker for iPad/iPhone. I checked everything from cocoacontrols but none of them matched my requirement. I don't like a color wheel or any control which takes the whole iPhone screen. I need something similar to this,

enter image description here

I found this article pretty useful.

But it's a PNG image based color picker. I need more accurate picker. Is there any open source control which is similar to this? If not I would like to write a custom picker myself but can someone point me in to a direction on where should I begin with?


Solution

  • Just write your own. It's a very simple control.

    Subclass UIControl.
    Implement drawRect: to draw the color gradient.
    Add a UIPanGestureRecognizer or implement the touch handling methods.
    Call [self sendActionsForControlEvents:UIControlEventValueChanged]; whenever the selected color changes.