a light way to make target-action to closure in Swift.UIKit with Swift4
// add events
control.add(.touchUpInside) { control in
// action
}
// or like this to convert type of control
control.add(.touchUpInside) { (btn: UIButton) in
// action
}
// remove events
control.remove(.touchUpInside) { btn in
// action
}
// test didAdd events
let res: Bool = control.didAdd(.touchUpInside)
let item = UIBarButtonItem.init(title: "test", style: .plain, { item in
// action
})
...
...
...
let r = UITapGestureRecognizer{ recognizer in
// action
}
......
code style is more like
than