【问题标题】:SwiftMessages Two ButtonsSwiftMessages 两个按钮
【发布时间】:2020-10-16 19:36:24
【问题描述】:

我在 swift 5 中有以下功能,可以使用 SwiftMessages cocoapod 显示带有确认按钮的消息。但我需要有 2 个单独的按钮(例如:确认和取消)。我怎样才能做到这一点?

    public static func choiceMessage(theme: Theme = .error, title: String, message: String, buttonTitle: String = "Confirm", completion: @escaping (Bool) -> Void){
    dispatchOnMain {
        SwiftMessages.hideAll()
        let view = MessageView.viewFromNib(layout: .messageView)
        var config = SwiftMessages.Config()
        view.configureTheme(theme)
        view.configureContent(title: title, body: message)
        view.button?.setTitle(buttonTitle, for: .normal)
        config.presentationStyle = .center
        config.duration = .forever
        config.dimMode = .blur(style: .dark, alpha: 1, interactive: true)
        view.buttonTapHandler = { _ in SwiftMessages.hide(); completion(true)}
        SwiftMessages.show(config: config, view: view)
        
    }
}

【问题讨论】:

    标签: swift5 swiftmessages


    【解决方案1】:

    你只需要

    • 创建自定义消息视图(您自己的 nib 文件) - 官方文档有很多参考资料
    • 或者只是动态添加和定位另一个按钮

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-06
      • 1970-01-01
      • 2020-04-08
      • 1970-01-01
      • 2023-02-09
      • 1970-01-01
      相关资源
      最近更新 更多