【问题标题】:How to set title of Button using ReactiveKit Bond?如何使用 ReactiveKit Bond 设置 Button 的标题?
【发布时间】:2017-04-03 19:45:36
【问题描述】:

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

【问题讨论】:

  • 如果你能解释你想要达到的目标并描述 rac_liftSelector 我可能会回答。

标签: ios reactivekit swiftbond


【解决方案1】:

通过创建 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)
            }
        }
    }

【讨论】:

    猜你喜欢
    • 2017-11-15
    • 1970-01-01
    • 2017-01-09
    • 2018-07-19
    • 2019-06-15
    • 1970-01-01
    • 1970-01-01
    • 2018-03-13
    • 1970-01-01
    相关资源
    最近更新 更多