-2

I want to use This library in swift. It's written in Obj-C.

I've added header and Bridging and etc, now, I don't know what is equivalent of this statement :

        //Color did change block declaration
    NKOColorPickerDidChangeColorBlock colorDidChangeBlock = ^(UIColor *color){
        //Your code handling a color change in the picker view.
    };

    NKOColorPickerView *colorPickerView = [[NKOColorPickerView alloc] initWithFrame:CGRectMake(0, 0, 300, 340) color:[UIColor blueColor] andDidChangeColorBlock:colorDidChangeBlock];

    //Add color picker to your view
    [self.view addSubview:colorPickerView];
Reza_Rg
  • 3,345
  • 7
  • 32
  • 48

1 Answers1

4
let colorPickerView = NKOColorPickerView(frame: CGRect(x: 0, y: 0, width: 300, height: 340), color: UIColor.blueColor()) { (color) -> Void in
    // Your code handling a color change in the picker view.
}

view.addSubview(colorPickerView)

or

var colorDidChangeBlock: NKOColorPickerDidChangeColorBlock = { (color) in
    // Your code handling a color change in the picker view.
}

let colorPickerView = NKOColorPickerView(frame: CGRect(x: 0, y: 0, width: 300, height: 340), color: UIColor.blueColor(), andDidChangeColorBlock: colorDidChangeBlock)
view.addSubview(colorPickerView)

I prefer the first way. Its more clear and easier to read.

Isuru
  • 30,617
  • 60
  • 187
  • 303