RxSwift/RxCocoa/iOS/UILabel+Rx.swift

35 lines
762 B
Swift
Raw Normal View History

//
// UILabel+Rx.swift
// RxCocoa
//
// Created by Krunoslav Zaher on 4/1/15.
2015-12-29 18:56:21 +03:00
// Copyright © 2015 Krunoslav Zaher. All rights reserved.
//
#if os(iOS) || os(tvOS)
2015-08-01 16:13:26 +03:00
#if !RX_NO_MODULE
2015-04-10 02:52:51 +03:00
import RxSwift
2015-08-01 16:13:26 +03:00
#endif
import UIKit
extension Reactive where Base: UILabel {
2016-10-23 20:26:22 +03:00
/// Bindable sink for `text` property.
public var text: UIBindingObserver<Base, String?> {
return UIBindingObserver(UIElement: self.base) { label, text in
2016-02-13 23:25:31 +03:00
label.text = text
}
}
2015-11-11 05:46:30 +03:00
2016-10-23 20:26:22 +03:00
/// Bindable sink for `attributedText` property.
public var attributedText: UIBindingObserver<Base, NSAttributedString?> {
return UIBindingObserver(UIElement: self.base) { label, text in
2016-02-13 23:25:31 +03:00
label.attributedText = text
}
2015-11-11 05:46:30 +03:00
}
}
#endif