自定义控件

自定义控件继承自UIControl

控件内部合适位置发送事件

// 自定义控件内部主动发送事件
sendActions(for: .valueChanged)

外部使用控件的时候监听事件

view.addTarget(self, action: #selector(pullDownRefreshing), for: .valueChanged)
原文地址:https://www.cnblogs.com/panda1024/p/6188848.html