Search code examples
iosswiftcocoapodscolor-picker

How to display color picker on button click, and on select of particular color i want to get a hex code of that color?


which is the best cocoapod of color pickets for ios application?

I am trying to implement DRColorPickerWheelView by installing cocoapods in my sample application, next I want to get the RGB value. How to get that - Please do help.

I am implementing as following,
correct me if I am wrong.

import UIKit

import DRColorPicker

class ViewController: UIViewController {

    override func viewDidLoad() {

        super.viewDidLoad()

        let img = UIImageView()
        img.image = DRColorPickerImage("colormap")
        img.frame = CGRect(x: 20, y: 90, width: 330, height: 300)

        view.addSubview(img)

        let v = DRColorPickerWheelView()
        v.frame = CGRect(x: 10, y: 40, width: 350, height: 400)

        view.addSubview(v)

        // Do any additional setup after loading the view, typically from a nib.
    }
}

Solution

  • try below code:

    let str = yourSelectedColorVariable.hexStringFromColor
    

    This category defined at: DRColorPicker