Skip to content

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

License

Notifications You must be signed in to change notification settings

springlo/WDColorPicker

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WDColorPicker

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

CocoaPods Compatible License Platform

Installation:

Manual

Download example project and add WDColorPickerView folder inside your project

CocoaPods:

target '<TargetName>' do
    use_frameworks!
    pod 'WDColorPicker', ' ~> 1.0.1'
end

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.

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 96.5%
  • Ruby 3.5%