1

I have the following function in swift 5 to display a message with confirm button using the SwiftMessages cocoapod. But I need to have 2 separate buttons (ex: confirm and cancel). How can I accomplish this?

    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)
        
    }
}
jakumpe
  • 41
  • 2
  • 4

1 Answers1

0

You just need to

  • create custom message view (your own nib file) - official docs has plenty of references
  • or just add and position another button dynamically