我正在创建一个自定义UIButton
。
因此,当应用程序使用此按钮时,显然有一个方法绑定(bind)到它的 UIControleventtouchdown 事件。我想在调用click方法之前进行一定的操作。
那么是否可以在传递到绑定(bind)到 UIControleventtouchdown
事件的方法之前拦截调用并执行一些操作?
最佳答案
如果您的 CustomButton
只是覆盖 sendAction(_:to:for:)
class CustomButton: UIButton {
override func sendAction(_ action: Selector, to target: Any?, for event: UIEvent?) {
// perform custom operations here
super.sendAction(action, to: target, for: event)
}
}
关于ios - 拦截事件或跟踪 iO 中自定义控件的事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44316743/