Last active
July 25, 2018 07:16
-
-
Save mcichecki/60488af640d8a585771e404529b38ec9 to your computer and use it in GitHub Desktop.
UITextField's extension to support isSecureTextEntry with RxCocoa
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 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