Latest 1.0.0
Homepage https://github.com/SilongLi/ColorPickerView
License MIT
Platforms ios 9.0, requires ARC
Authors

ColorPickerView

学习Keynote,写了个属于自己的颜色选择器,用CALayer和其子类显示颜色条,用UIWindow自己封装成MenuController等等,代码高度内聚(一个类搞定),且简单实用。

CocoaPods集成

  pod 'LSLColorPickerView'

一、实用说明:

1.实例化


    /// color picker view (size must be given)
    _colorPickerView = [[LSLHSBColorPickerView alloc] initWithFrame:_contentView.bounds];   
    [_contentView addSubview:_colorPickerView]; 

    /// selected color preview  
    _currentSelectedColorPreview.backgroundColor = _colorPickerView.preColor;

    /// selected color block    
    __weak typeof(self) weakSelf = self;    
    [_colorPickerView colorSelectedBlock:^(UIColor *color, BOOL isConfirm) {    
        /// do something... 
        /// 
        weakSelf.currentSelectedColorPreview.backgroundColor = color;   
        weakSelf.currentSelectedColor = color;  
    }]; 

2.保存(或清空)本地文档(归档)中的数据

#pragma mark - save or clean colors in archiver

- (IBAction)saveSelectedColorToArchiver {
    if (self.currentSelectedColor) {
        [self.colorPickerView saveSelectedColorToArchiver];
        self.currentSelectedColor = nil;
    }
}

- (IBAction)cleanCache:(id)sender {
    [LSLHSBColorPickerView cleanSelectedColorInArchiver];
}

二、GIF演示

Latest podspec

{
    "name": "LSLColorPickerView",
    "version": "1.0.0",
    "summary": "u4e00u4e2au5f88u7b80u6d01u5b9eu7528u7684u989cu8272u9009u62e9u5668u3002",
    "description": "u5b66u4e60Keynoteuff0cu5199u4e86u4e2au5c5eu4e8eu81eau5df1u7684u989cu8272u9009u62e9u5668uff0cu7528CALayeru548cu5176u5b50u7c7bu663eu793au989cu8272u6761uff0cu7528UIWindowu81eau5df1u5c01u88c5u6210MenuControlleru7b49u7b49uff0cu4ee3u7801u9ad8u5ea6u5185u805auff08u4e00u4e2au7c7bu641eu5b9auff09uff0cu4e14u7b80u5355u5b9eu7528u3002",
    "homepage": "https://github.com/SilongLi/ColorPickerView",
    "license": {
        "type": "MIT"
    },
    "authors": {
        "Bruce Li": "lisilongios@163.com"
    },
    "platforms": {
        "ios": "9.0"
    },
    "source": {
        "git": "https://github.com/SilongLi/ColorPickerView.git",
        "tag": "1.0.0"
    },
    "source_files": "LSLColorPikerDemo/ColorPickerClass/*",
    "requires_arc": true
}

Pin It on Pinterest

Share This