diff --git a/Source/UIKit/UILabel.swift b/Source/UIKit/UILabel.swift index d353f5e..c999eec 100644 --- a/Source/UIKit/UILabel.swift +++ b/Source/UIKit/UILabel.swift @@ -14,4 +14,8 @@ extension UILabel { public var rex_text: MutableProperty { return rex_stringProperty("text") } + + public var rex_textColor: MutableProperty { + return rex_valueProperty(&textColor, { [weak self] in self?.textColor ?? UILabel().textColor }, { [weak self] in self?.textColor = $0 }) + } } diff --git a/Tests/UIKit/UILabelTests.swift b/Tests/UIKit/UILabelTests.swift index e365e28..24c64c4 100644 --- a/Tests/UIKit/UILabelTests.swift +++ b/Tests/UIKit/UILabelTests.swift @@ -42,4 +42,20 @@ class UILabelTests: XCTestCase { observer.sendNext(secondChange) XCTAssertEqual(label.text, secondChange) } + + func testTextColorProperty() { + let firstChange = UIColor.redColor() + let secondChange = UIColor.blackColor() + + let label = UILabel(frame: CGRectZero) + + let (pipeSignal, observer) = Signal.pipe() + label.textColor = UIColor.blackColor() + label.rex_textColor <~ SignalProducer(signal: pipeSignal) + + observer.sendNext(firstChange) + XCTAssertEqual(label.textColor, firstChange) + observer.sendNext(secondChange) + XCTAssertEqual(label.textColor, secondChange) + } }