Objective c swift中Obj-C alloc语句的等价物
我想在swift中使用这个库。它是用Obj-C写的 我已经添加了标题和桥接等,现在,我不知道这句话的等价物是什么:Objective c swift中Obj-C alloc语句的等价物,objective-c,iphone,xcode,swift,alloc,Objective C,Iphone,Xcode,Swift,Alloc,我想在swift中使用这个库。它是用Obj-C写的 我已经添加了标题和桥接等,现在,我不知道这句话的等价物是什么: //Color did change block declaration NKOColorPickerDidChangeColorBlock colorDidChangeBlock = ^(UIColor *color){ //Your code handling a color change in the picker view.
//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];
或
我喜欢第一条路。它更清晰易读。哇,太棒了!非常感谢。
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)
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)