A color picker for iOS
Objective-C Swift Ruby
Latest commit 22d8ea7 Jul 16, 2016 @fcanas committed on GitHub Add explicit file dependencies to README
For users not using cocoapods, it's not clear that the xib and png are
Dependencies.

Fixes #14

README.md

iOS Color Picker

Version License Platform

A reusable color picker component for iOS. Works for iPhone, iPad, in modal sheets, popovers... just about anywhere.

Using iOS-Color-Picker

Installation

The easiest way to use iOS-Color-Picker is with CocoaPods. Add the following line to your Podfile.

pod 'iOS-Color-Picker'

Otherwise, you need to include the following files in your project:

  • FCColorPickerViewController.h
  • FCColorPickerViewController.m
  • FCColorPickerViewController.xib
  • Resources/colormap.png

Using a Color Picker from a View Controller

Suppose you have a view controller with a color property you'd like to let the user pick. Make your view controller implement the FCColorPickerViewControllerDelegate protocol. Handle the color picked and the cancelled methods, and make a method that triggers showing the view controller.

-(IBAction)chooseColor:(id)sender {
    FCColorPickerViewController *colorPicker = [FCColorPickerViewController colorPicker];
    colorPicker.color = self.color;
    colorPicker.delegate = self;

    [colorPicker setModalPresentationStyle:UIModalPresentationFormSheet];
    [self presentViewController:colorPicker animated:YES completion:nil];
}

#pragma mark - FCColorPickerViewControllerDelegate Methods

-(void)colorPickerViewController:(FCColorPickerViewController *)colorPicker didSelectColor:(UIColor *)color {
    self.color = color;
    [self dismissViewControllerAnimated:YES completion:nil];
}

-(void)colorPickerViewControllerDidCancel:(FCColorPickerViewController *)colorPicker {
    [self dismissViewControllerAnimated:YES completion:nil];
}

The color picker has tintColor and backgroundColor properties for configuring its appearance.

Screenshots

iPhone

iPhone 5

iPhone 5

iPad

iPhone 5

iPhone 5

Example Project

An example project is included in /Example. Run pod install in the example directory to configure the project, then open the Xcode workspace.