An open API service indexing awesome lists of open source software.

https://github.com/kautenja/uipopupcolorpicker

a simple PopupDialog for picking a color from a list of colors
https://github.com/kautenja/uipopupcolorpicker

carthage color-palette color-picker ios ios-framework popup-dialog ui-components

Last synced: 3 months ago
JSON representation

a simple PopupDialog for picking a color from a list of colors

Awesome Lists containing this project

README

          

# UIPopupColorPicker

[![swift-badge][]][swift-link]
[![carthage-badge][]][carthage-link]

[swift-badge]: https://img.shields.io/badge/swift-4.0-orange.svg
[swift-link]: https://swift.org/
[carthage-badge]: https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat
[carthage-link]: https://github.com/Carthage/Carthage

## 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:

```ruby
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:

```swift
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

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

#### Callback

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

```swift
/// Handle a color selection from UIPopupColorPicker
func colorDidChange(to color: UIColor?) {

}

let _ = UIPopupColorPicker.show(on: self, block: colorDidChange)
```

or like this using an escaping closure

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

### Code Samples

see [ViewController](PopupColorPicker/ViewController.swift) 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](./LICENSE) file for more
info.