WDColorPicker 1.0.1

WDColorPicker 1.0.1

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Feb 2018
SwiftSwift Version 3.1
SPMSupports SPM

Maintained by Vladimir Dinic.



  • By
  • Vladimir Dinic

WDColorPicker is a simple lightweight component for displaying color picker inside iOS apps.

Installation:

Manual

Download example project and add WDColorPickerView folder inside your project

Usage

Add color picker as interface component

GitHub Logo

  1. Add UIView in storyboard / xib file and subclass it with WDColorPickerView class from WDColorPicker module
  2. Implement WDColorPickerViewDelegate method func colorChanged(colorPicker: WDColorPickerView, color: UIColor) to handle color changes:
//Example of usage
import UIKit
import WDColorPicker    //If you are using CocoaPods

class InterfaceColorPickerViewController: UIViewController, WDColorPickerViewDelegate
{
    @IBOutlet weak var colorPicker: WDColorPickerView!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        self.colorPicker.delegate = self
    }
    
    func colorChanged(colorPicker: WDColorPickerView, color: UIColor) {
        self.view.backgroundColor = color
    }
}

Show color picker as pop up

GitHub Logo

  1. Implement WDColorPickerViewDelegate method func colorSelected(colorPicker: WDColorPickerView, color: UIColor) to handle color selection:
//Example of usage
import UIKit
import WDColorPicker    //If you are using CocoaPods

class PopUpColorPickerViewController: UIViewController, WDColorPickerViewDelegate
{
    
    @IBOutlet weak var colorButton: UIButton!
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }
    
    @IBAction func shwColorPicker(_ sender: Any) {
        WDColorPickerView.showPicker(delegate: self, initialColor: self.colorButton.backgroundColor)
    }
    
    func colorSelected(colorPicker: WDColorPickerView, color: UIColor) {
        self.colorButton.backgroundColor = color
    }
}

Note:

Documentation is still in preparation and the code will be updated regularly
If you find any bug, please report it, and I will try to fix it ASAP.