如何使用ReactiveKit Bond设置Button的标题?

时间:2017-04-03 19:45:37

标签: ios reactivekit swiftbond

在Reactivekit中是否有等效的rac_liftSelector来实现setTitle的选择器?

1 个答案:

答案 0 :(得分:0)

通过创建ReactiveExtension来解决它。

extension ReactiveExtensions where Base: UIButton {
        var Title: Bond<String?> {
            return bond { button, text in
                let attributedString = NSAttributedString(string: text!)
                button.setAttributedTitle(attributedString, for: UIControlState.normal)
            }
        }
    }