Created
May 14, 2015 14:19
-
-
Save t-kashima/f53d07d7585b050c4b12 to your computer and use it in GitHub Desktop.
ReactiveCocoa for swift
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 UIKit | |
import ReactiveCocoa | |
class ViewController: UIViewController { | |
@IBOutlet var textInput: UITextField! | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// Do any additional setup after loading the view, typically from a nib. | |
var textSignal = self.textInput.rac_textSignal() | |
textSignal.map { | |
(text: AnyObject!) -> AnyObject! in | |
var textString = text as! NSString | |
if 3 >= textString.length { | |
return UIColor.lightGrayColor() | |
} | |
return UIColor.whiteColor() | |
} | |
.setKeyPath("backgroundColor", onObject: self.textInput) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment