Skip to content

Instantly share code, notes, and snippets.

@alanf
Created July 27, 2017 20:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alanf/4de565da4263863c88977958d08eef95 to your computer and use it in GitHub Desktop.
Save alanf/4de565da4263863c88977958d08eef95 to your computer and use it in GitHub Desktop.
import ReactiveKit
import UIKit
class UnderlinedTextField: UITextField {
@IBOutlet weak var underlineView: UIView!
override func awakeFromNib() {
super.awakeFromNib()
underlineView.backgroundColor = UIColor.lightGray
// Highlight/unhighlight the underlined view when it's being edited.
reactive.controlEvents(.editingDidBegin).map { _ in
return UIColor.green
}.bind(to: underlineView.reactive.backgroundColor).dispose(in: reactive.bag)
reactive.controlEvents(.editingDidEnd).map { _ in
return UIColor.lightGray
}.bind(to: underlineView.reactive.backgroundColor).dispose(in: reactive.bag)
}
}
@priofy
Copy link

priofy commented Nov 4, 2018

Dear Alan,

I have been trying since today morning to fix this error but something is wrong. I installed cocoa and all the kits required but it still gives me this error:

/Users/.../ViewController.swift:31:54: Value of type 'Signal<UIColor, NoError>' has no member 'bind'

I
screen shot 2018-11-04 at 5 03 15 pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment