Last active
March 30, 2022 13:11
-
-
Save agrawalsuneet/f08c850869a53d1f14378344337d82eb to your computer and use it in GitHub Desktop.
Extension to UISwitch to add switch value change event in a clean way
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
//MARK: - UISwitch Extension | |
@available(iOS 14.0, *) | |
extension UISwitch { | |
func setOnValueChangeListener(onValueChanged :@escaping () -> Void){ | |
self.addAction(UIAction(){ action in | |
onValueChanged() | |
}, for: .valueChanged) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment