Last active
May 23, 2020 19:55
-
-
Save MathVasc/3769557cab7144b448a9b25eaa19fe46 to your computer and use it in GitHub Desktop.
sendFakeActions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) | |
| } | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment