Skip to content

Instantly share code, notes, and snippets.

@MathVasc
Created May 23, 2020 19:55
Show Gist options
  • Select an option

  • Save MathVasc/4b3983e6cef7815b79f8961e559d1d2d to your computer and use it in GitHub Desktop.

Select an option

Save MathVasc/4b3983e6cef7815b79f8961e559d1d2d to your computer and use it in GitHub Desktop.
sendFakeActionWithParameter
import UIKit
public extension UIControl {
func sendFakeAction(for controlEvent: UIControl.Event) {
allTargets.forEach { target in
guard let actions = actions(forTarget: target, forControlEvent: controlEvent),
let responder = target.base as? NSObject else {
return
}
actions.map { Selector($0) }.forEach { selector in
if responder.responds(to: selector) {
responder.perform(selector, with: self)
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment