iOS-Color-Picker 1.2

iOS-Color-Picker 1.2

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布最后发布2018年5月

Fabian Canas 维护。



  • 作者
  • Fabian Canas

iOS Color Picker

Version License Platform

一个可重用颜色选择器组件,适用于iOS。适用于iPhone、iPad、模态表单、弹窗等几乎所有地方。

使用iOS-Color-Picker

安装

使用iOS-Color-Picker的最简单方法是使用CocoaPods。将以下行添加到您的 Podfile

pod 'iOS-Color-Picker'

否则,您需要将以下文件包含到您的项目中

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

从视图控制器中使用颜色选择器

假设您有一个视图控制器,其中包含一个您希望用户可挑选的 颜色 属性。使您的视图控制器实现 FCColorPickerViewControllerDelegate 协议。处理所选颜色和取消的方法,并创建一个触发显示视图控制器的方法。

-(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];
}

调色板具有 tintColorbackgroundColor 属性,用于配置其外观。

屏幕截图

iPhone

iPhone 5

iPhone 5

iPad

iPhone 5

iPhone 5

示例项目

示例项目包含在 /Example 中。在示例目录中运行 pod install 以配置项目,然后打开 Xcode 工作空间。