1.block属性的定义:
var completeBtnClickBlock: (()->())? // 无参block
var backNameBlock: ((String,String)->())? // 含参block
2.block的调用:
//“完成”按钮点击
@IBAction func completeBtnAction(_ sender: Any) {
guard self.completeBtnClickBlock != nil && self.backNameBlock != nil else {
return
}
self.completeBtnClickBlock!()
self.backNameBlock!("hushijie","hushituan")
}
3.block的实现
weak var weakSelf = self
paySuccessView.completeBtnClickBlock = { ()->() in
weakSelf?.navigationController?.popViewController(animated: true)
}
paySuccessView.backNameBlock = { (name1,name2)->() in
print(name1)
print(name2)
}