Is there a color picker library/code for iPhone development?

35,308

Solution 1

Yes there is an open source code for color picker you can use in your application. here is one http://www.fabiancanas.com/entry/iphone-color-picker

Solution 2

Here is a color-picker with the following features:

  • Shows a simple color pallete (simplifies the simple case), hue-grid or HSL selector.
  • iPhone 5 ready - color pallete expands to fill larger screen.
  • Hue grid - more variations of primary color. Color line in the bottom can be tapped to select color or grid can be swiped left and right.
  • HSL selector - for fine grain color selection, presents Hue circle and separate saturation and luminosity controls.
  • Alpha selector
  • Allows users to save their favorite colors. Favorites are stored in a file in the Documents directory.
  • Simple delegate model.
  • You can specify current color selection and title for header.

Screenshots: enter image description here enter image description here enter image description here

Solution 3

My full answer is here. If you don't want to use your own code rather than a third party library, you can do something like the following:

Make your own color picker

Add a UIView, a UIImageView, and a UISlider to the storyboard.

enter image description here

Use this image for the UIImageView:

enter image description here

Set the min and max values for the UISlider to 0.5 and 13.5.

Hook up the UI elements to the View Controller and use the following code to convert the slider position to colors.

class ViewController: UIViewController {
 
    // RRGGBB hex colors in the same order as the image
    let colorArray = [ 0x000000, 0xfe0000, 0xff7900, 0xffb900, 0xffde00, 0xfcff00, 0xd2ff00, 0x05c000, 0x00c0a7, 0x0600ff, 0x6700bf, 0x9500c0, 0xbf0199, 0xffffff ]
    
    @IBOutlet weak var selectedColorView: UIView!
    @IBOutlet weak var slider: UISlider!
    @IBAction func sliderChanged(sender: AnyObject) {
        selectedColorView.backgroundColor = uiColorFromHex(colorArray[Int(slider.value)])
    }
   
    func uiColorFromHex(rgbValue: Int) -> UIColor {
        
        let red =   CGFloat((rgbValue & 0xFF0000) >> 16) / 0xFF
        let green = CGFloat((rgbValue & 0x00FF00) >> 8) / 0xFF
        let blue =  CGFloat(rgbValue & 0x0000FF) / 0xFF
        let alpha = CGFloat(1.0)
        
        return UIColor(red: red, green: green, blue: blue, alpha: alpha)
    }
}

enter image description here

Or by positioning the slider on top of the image and setting the track tints to clear:

enter image description here

Solution 4

check this URL.This may help you.http://maniacdev.com/2011/11/open-source-ios-color-picker-components-roundup/

Solution 5

I wrote a very simple one in Swift. It's probably not the best, but it looks nice and it's very simple.

https://github.com/EthanStrider/iOS-Projects/tree/master/ColorPickerExample

Image Picker Screenshot

Share:
35,308
Greg
Author by

Greg

Updated on April 09, 2020

Comments

  • Greg
    Greg about 4 years

    Is there an existing "color picker" library for iPhone development that I could leverage for my app?