简体   繁体   English

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

[英]How to set title of Button using ReactiveKit Bond?

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

Resolved it by creating a ReactiveExtension. 通过创建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)
            }
        }
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM