Skip to content

Commit

Permalink
Merge pull request #62 from iv-mexx/UILabelTextColor
Browse files Browse the repository at this point in the history
add `rex_textColor` to UILabel
  • Loading branch information
neilpa committed Nov 22, 2015
2 parents 677d660 + a071507 commit ef8d2b1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Source/UIKit/UILabel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@ extension UILabel {
public var rex_text: MutableProperty<String> {
return rex_stringProperty("text")
}

public var rex_textColor: MutableProperty<UIColor> {
return rex_valueProperty(&textColor, { [weak self] in self?.textColor ?? UILabel().textColor }, { [weak self] in self?.textColor = $0 })
}
}
16 changes: 16 additions & 0 deletions Tests/UIKit/UILabelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<UIColor, NoError>.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)
}
}

0 comments on commit ef8d2b1

Please sign in to comment.