Observing UITextField.editing with RxSwift

前端 未结 3 829
别那么骄傲
别那么骄傲 2021-02-04 00:13

I want to observe the property UITextfield.editing. I\'m using this code:

self.money.rx_observe(Bool.self, \"editing\").subscribeNext { (value) in
          


        
3条回答
  •  我在风中等你
    2021-02-04 00:55

    Since RxSwift 4.0, there is two specific control events : textDidBeginEditing and textDidEndEditing

    You can used it like this :

    textField.rx.textDidEndEditing
                .asObservable()
                .subscribe(onNext: {
                    print("End of edition")
                }).disposed(by: disposeBag)
    
    
    textField.rx.textDidBeginEditing
                    .asObservable()
                    .subscribe(onNext: {
                        print("Start of edition")
                    }).disposed(by: disposeBag)
    

提交回复
热议问题