importUIKit
@objcprotocolDetailedViewControllerDelegate {
@objcoptionalfuncchangeValue (value:Int) ->Void;
}
classDetailedViewController:UIViewController{
var_title:String?
vardelegate:DetailedViewControllerDelegate?
varcount:Int=0
varchangeBlock:((Int) -> ())?
overridefuncviewDidLoad() {
super.viewDidLoad()
navigationItem.title=_title
self.view.backgroundColor=UIColor.brown
weakvarweakSelf =self
letbtn =CGButton.shendInstance().createButton(frame:CGRect(), bgColor:UIColor.red, title:"按钮", superView:self.view) { (action)in
weakSelf?.count+=1
letcout = weakSelf?.count
// Block回调
if(weakSelf?.changeBlock! !=nil) {
weakSelf?.changeBlock!(cout!)
}
// 代理回调
if((weakSelf?.delegate?.changeValue) !=nil) {
weakSelf?.delegate?.changeValue!(value: cout!)
}
}
}
funcchangeValue(value:@escaping(Int) -> ()) ->Void{
self.changeBlock= value
}
}
近期评论