YSColorPicker
YSColorPicker is an easy-to-use swift color picker library for iOS.
Features
-RGB
-RGBA
-HSB
-HSBA
-ColorPicker
-ColorPicker (alpha)
You can select any number from these modes.
Installation
CocoaPods
- Add pod
'YSColorPicker',: git => 'https: // github.com / sekies / YSColorPicker.git'
to Podfile. - Do a pod install.
Usage
- Import YSColorPicker.
Swift import YSColorPicker
- Comply with the
YSColorsTabViewControllerDelegate
protocol on any UIViewContoroller.
Swift class ViewController: UIViewController, YSColorsTabViewControllerDelegate {
- Create a
YSColorsTabViewController
instance when you want to use the color picker. Specify the initial color and picker type at generation time.
Swift let tabvc = YSColorsTabViewController (color: .blue, colorTypes: [ .YS_COLOR_RGB, .YS_COLOR_RGBA, .YS_COLOR_HSB, .YS_COLOR_HSBA ])
- The color picker is displayed as TabViewController. Set background color of view and delegate and open it modally.
* Please note that the delegate setting is ysColorDelegate.
Swift tabvc.view.backgroundColor = .white tabvc.ysColorDelegate = self present (tabvc, animated: true, completion: nil)
The type can be specified from the following 6 types.
.YS_COLOR_PICKER, .YS_COLOR_PICKERA, .YS_COLOR_RGB, .YS_COLOR_RGBA, .YS_COLOR_HSB, .YS_COLOR_HSBA
- Implement the delegate method. This method is called whenever the color changes on the picker.
Swift func ysChanged (color: UIColor) { print (color) }