项目作者: Kautenja

项目描述 :
a simple PopupDialog for picking a color from a list of colors
高级语言: Swift
项目地址: git://github.com/Kautenja/UIPopupColorPicker.git
创建时间: 2017-07-18T07:06:05Z
项目社区:https://github.com/Kautenja/UIPopupColorPicker

开源协议:MIT License

下载


UIPopupColorPicker

swift-badge
carthage-badge

Screenshots

The standard theme

An example of custom theme utilizing tint color, font, and a custom list of colors

Installation

Carthage

add the folowing to your Carfile:

  1. github "kautenja/UIPopupColorPicker" ~> 1.1

Example

To run the example project, clone the repo, and it in Xcode on devices of your choosing, there is an example UI
setup to access the picker.

Code Usage

Creation

UIPopupColorPicker is accessed through the single static function:

  1. let _ = UIPopupColorPicker.show(on: self, block: nil)

This function returns an instance of BColorPicker in case you might want to
manipulate some of the controller manually.

Customization

  1. let popup = UIPopupColorPicker.show(on: self, block: nil)
  2. popup.tintColor = #colorLiteral(red: 0.1568514521,
  3. green: 0.680490051,
  4. blue: 0.9768045545,
  5. alpha: 1)
  6. popup.buttonFont = UIFont(name: "HelveticaNeue", size: 18.0)!
  7. popup.colorList = [UIColor.gray, UIColor.blue, UIColor.yellow]

Callback

One way of handling color change is to implement a handler function

  1. /// Handle a color selection from UIPopupColorPicker
  2. func colorDidChange(to color: UIColor?) {
  3. }
  4. let _ = UIPopupColorPicker.show(on: self, block: colorDidChange)

or like this using an escaping closure

  1. let _ = UIPopupColorPicker.show(on: self) { color in
  2. // handle color change with escaping closure
  3. }

Code Samples

see ViewController for a working example of the popup.

License

TL;DR do what you want with it.

UIPopupColorPicker is available under the MIT license. See the LICENSE file for more
info.