Skip to content

miquelbotanch/ios-color-picker

 
 

Repository files navigation

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'

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.

About

A color picker for iOS

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Objective-C 72.3%
  • Swift 20.0%
  • Ruby 7.7%