Skip to content

Instantly share code, notes, and snippets.

@mcichecki
Last active July 25, 2018 07:16
Show Gist options
  • Save mcichecki/60488af640d8a585771e404529b38ec9 to your computer and use it in GitHub Desktop.
Save mcichecki/60488af640d8a585771e404529b38ec9 to your computer and use it in GitHub Desktop.
UITextField's extension to support isSecureTextEntry with RxCocoa
import RxCocoa
import RxSwift
extension Reactive where Base: UITextField {
var isSecureTextEntry: Binder<()> {
return Binder(base, binding: { (textField, _) in
textField.isSecureTextEntry = !textField.isSecureTextEntry
})
}
}
// use case:
/*
changePasswordVisibilityButton.rx.tap
.bind(to: self.rx.isSecureTextEntry)
.disposed(by: disposeBag)
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment