Code Monkey home page Code Monkey logo

colorpicker's Introduction

Color Picker

Background

A color picker is the most conspicuously absent component in the collection of built-in controls provided by Apple in the iOS library. There are many open-source components that have sprung up to fill the gap. This component was created for the [ToonThat][https://itunes.apple.com/us/app/toonthat/id584478951?ls=1&mt=8] application as we didn't find the level of flexibility and feature-set in the others.

Screenshots

Simple selector Hue Grid selector HSL selector

Features

  • Shows a simple color pallete (simplifies the simple case).
  • iPhone 5 ready - color pallete expands to fill larger screen.
  • Hue grid - more variations of primary color. Color line in the bottom can be tapped to select color or grid can be swiped left and right.
  • HSL selector - for fine grain color selection, presents Hue circle and separate saturation and luminosity controls.
  • Alpha selector
  • Allows users to save their favorite colors. Favorites are stored in a file in the Documents directory.
  • Simple delegate model.
  • You can specify current color selection and title for header.

Usage

Copy the files within the Source folder into your project. The colorPicker.bundle file contains the graphical resources.

In your view controller where you want to invoke the color picker, first implement the methods of the delegate:

@implementation MyViewController <NEOColorPickerViewControllerDelegate>

Assuming you want to launch the view controller in response to a button being clicked, setup and launch an instance of NEOColorPickerViewController:

NEOColorPickerViewController *controller = [[NEOColorPickerViewController alloc] init];
controller.delegate = self;
controller.selectedColor = <some initial color reference>;
controller.title = @"My dialog title";
UINavigationController* navVC = [[UINavigationController alloc] initWithRootViewController:controller];
[self presentViewController:navVC animated:YES completion:nil];

Finally handle the color picker delegate callback when the color is selected or cancelled:

- (void) colorPickerViewController:(NEOColorPickerBaseViewController *)controller didSelectColor:(UIColor *)color {
    // Do something with the color.    
    self.view.backgroundColor = color;
    [controller dismissViewControllerAnimated:YES completion:nil];
}

- (void) colorPickerViewControllerDidCancel:(NEOColorPickerBaseViewController *)controller {
    [controller dismissViewControllerAnimated:YES completion:nil];
}

License

Apache License 2.0

colorpicker's People

Contributors

jjxtra avatar kartech avatar csteynberg avatar jejohnsonancestry avatar akkyie avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.