I'm trying to add a color picker to my iOS application, using Xcode 5. It appears that Xcode offers a color well via the Palettes Panel of Interface Builder, but I can't find the Palettes Panel (nor can I find any documentation of it online beyond that link).
That link also suggests an NSColorWell
can be added programatically. I'd prefer to go the Interface Builder route, but if that's not an option sample code would be welcome.
There is another cool color picker made by kartech. It has awesome UI for the selection of colors. Moreover you can mark colors as favorite. Link is here.
Screenshots:
I had the same question as you. It's unfortunate that there is no built in color picker for iOS. The other answers here and for similar questions mainly use third party libraries or projects. I prefer to avoid all the third party stuff whenever possible, so that leaves us with...
Make your own color picker
There are many ways you could do it, but here is a simple example to show the concept. I set up my story board like this:
It has a
UIView
(grey here) to show the chosen color, aUIImageView
to show the color choices, and aUISlider
to choose the color. I used the following image in theUIImageView
:I made it from the colors of a 12-spoke color wheel using a screen shot and Gimp's color picker tool. Gimp is also useful for getting the color hex codes we will use later.
Set the min and max values for the Slider to 0.5 and 13.5. Converting the slider values to integers later will give one number for each of the colors in our image. Starting at 0.5 rather than 0 makes the slider color change location match the image better.
Hook up the UI elements to the View Controller and use the following code to convert the slider position to colors.
Now if you run it, you can choose the color by moving the slider back and forth.
Variations
Use an array of UIColors to avoid having to do the hex conversion.
Could use multiple UIViews rather than an image, and then set the colors directly from the array.
Further study
I thought I would throw my color picker into the ring. I use it in my app, You Doodle and I spent a couple weeks making it and testing it in the app. It contains a sample project to show you how to get started with it and is open sourced under the MIT license. It supports any device (iOS 6+), any resolution and portrait and landscape. Favorites, recents, color by hue, color wheel and importing textures, as well as deleting and moving favorites to the front is supported.
I've tried to combine the good pieces of all the other color pickers and ensure that the MIT license allows a no hassle integration into any project.
Github: https://github.com/jjxtra/DRColorPicker
Screenshots: