iOS顏色選擇器:CHColorPickerView

jopen 10年前發布 | 20K 次閱讀 iOS開發 移動開發 CHColorPickerView

CHColorPickerView 是 iOS 非常容易使用的顏色選擇器,只有一個委托方法,支持 iPhone 和 iPad。

用法

  • Refer to the Demo project.
  • Drag and Drop CHColorPicker.h/.m into your project
  • Implement the delegate method in your ViewController

使用 ColorPicker (示例)

    colorPickerView = [[CHColorPickerView alloc] init];


    // 1. Setup delegate (Implement delegate methods)

    colorPickerView.delegate = self;



    // 2. Setup desired behaviour

    colorPickerView.colorsPerRow = 4;
    colorPickerView.colorCellPadding = 2.0;

    colorPickerView.highlightSelection = YES;
    colorPickerView.selectionBorderColor = [UIColor whiteColor];


    // 3. Set colors that should be available as an NSArray

    [colorPickerView setColors:[self createDemoColor]];


    // 4 Do some styling

    colorPickerView.backgroundColor = [UIColor colorWithHexString:@"1d2225"];


    // 5. add to view hierachy

    [self.view addSubview:colorPickerView];

實現 delegate

    -(void)colorPickerView:(CHColorPickerView *)colorPickerView didSelectColor:(UIColor *)color; 

iOS顏色選擇器:CHColorPickerView

項目主頁:http://www.baiduhome.net/lib/view/home/1406105496882

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!