Adds `UIButton.setTitle` extensions to tvOS.

This commit is contained in:
Krunoslav Zaher 2016-06-26 14:37:10 +02:00
parent 7a15347943
commit 933cb02cb0
1 changed files with 20 additions and 9 deletions

View File

@ -22,15 +22,6 @@ extension UIButton {
public var rx_tap: ControlEvent<Void> {
return rx_controlEvent(.TouchUpInside)
}
/**
Reactive wrapper for `setTitle(_:controlState:)`
*/
public func rx_title(controlState: UIControlState = .Normal) -> AnyObserver<String?> {
return UIBindingObserver<UIButton, String?>(UIElement: self) { (button, title) -> () in
button.setTitle(title, forState: controlState)
}.asObserver()
}
}
#endif
@ -55,3 +46,23 @@ extension UIButton {
}
#endif
#if os(iOS) || os(tvOS)
import Foundation
#if !RX_NO_MODULE
import RxSwift
#endif
import UIKit
extension UIButton {
/**
Reactive wrapper for `setTitle(_:controlState:)`
*/
public func rx_title(controlState: UIControlState = .Normal) -> AnyObserver<String?> {
return UIBindingObserver<UIButton, String?>(UIElement: self) { (button, title) -> () in
button.setTitle(title, forState: controlState)
}.asObserver()
}
}
#endif