iOS 7.0以上版本的颜色收集选择器,包含Crayola和Pantone颜色。
pod install 'KKColorListPicker'
首先
#import "KKColorListPicker.h"
然后在您的控制器中,例如
- (IBAction)PresentColorList:(id)sender {
KKColorListViewController *controller = [[KKColorListViewController alloc] initWithSchemeType:KKColorsSchemeTypePantone];
controller.delegate = self;
[self presentViewController:controller animated:YES completion:nil];
}
或者您可以将KKColorListViewController作为根控制器放入UINavigationController
- (IBAction)presentInNavController:(id)sender {
KKColorListViewController *controller = [[KKColorListViewController alloc] initWithSchemeType:KKColorsSchemeTypeCrayola];
controller.delegate = self;
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:controller];
[self presentViewController:navController animated:YES completion:nil];
}
用于获取选中颜色的代理方法
- (void)colorListController:(KKColorListViewController *)controller didSelectColor:(KKColor *)color;
您可以简单地自定义颜色列表控制器的外观
@property (nonatomic, strong) NSString *headerTitle;
@property (nonatomic, strong) UIColor *selectedCellBorderColor;
@property (nonatomic, assign) CGFloat selectedCellBorderWidth;
@property (nonatomic, strong) UIColor *backgroundColor;
MIT许可证