I haven't managed to get it used by ObjC code...
SwiftMessages uses data structures that can't be seen by Objective-C. So it isn't possible. What you can do is write your own helper function in Swift that can be seen by Objective-C and call that:
swift
func showErrorMessage(title: String, subtitle: String) {
// show message here
}
@mattem86 Can you explain how you made this work?
Hi, yes of course:
I made a class "Messenger" in Swift:
import Foundation
import UIKit
import SwiftMessages
let status2 = MessageView.viewFromNib(layout: .StatusLine)
open class Messenger : NSObject {
open class func showStatusBarMessage(_ msg: String, color: UIColor, sender: UIViewController) {
status2.backgroundView.backgroundColor = color
status2.bodyLabel?.textColor = UIColor.white
status2.configureContent(body: msg)
var status2Config = SwiftMessages.defaultConfig
status2Config.preferredStatusBarStyle = UIStatusBarStyle.lightContent
status2Config.duration = .forever
status2Config.presentationContext = .automatic
SwiftMessages.show(config: status2Config, view: status2)
}
}
and call it from my Objective-C class like (of course I have to #import my "Module"-Swift.h in it):
[Messenger showStatusBarMessage:@"Blabla" color:[UIColor colorWithRed:0.25 green: 0.43 blue: 0.10 alpha:1.0] sender:self];
Hope this helps...!
You have to add "@objc" start of method
@objc
open class func showStatusBarMessage
Most helpful comment
Hi, yes of course:
I made a class "Messenger" in Swift:
and call it from my Objective-C class like (of course I have to #import my "Module"-Swift.h in it):
[Messenger showStatusBarMessage:@"Blabla" color:[UIColor colorWithRed:0.25 green: 0.43 blue: 0.10 alpha:1.0] sender:self];Hope this helps...!