SwiftMessages: A Flexible Alert Library For iOS

Alexander Paterson
|
Posted over 6 years ago
|
1 minute
SwiftMessages: A Flexible Alert Library For iOS
No more UIAlerts: finally something prettier

This blog is really about the joys of open-source software. I want to bring your attention to a neat little Swift library I found called SwiftMessages; it's a set of views that will come in handy in basically any app.

Need an ephemeral tiny line of text covering the status bar? Or even an entire modal menu? SwiftMessages can help.

SwiftMessages Demo

There are neat controls for everything from appearance duration to shadow/dim effects, and numerous preconfigured views. It's even easy to throw your own UIView into one of these cards, as in the documentation:

// Instantiate MessageView from a named nib.
let view: MessageView = try! SwiftMessages.viewFromNib(named: "MyCustomNib")

// Instantiate MyCustomView from a nib named MyCustomView.nib.
let view: MyCustomView = try! SwiftMessages.viewFromNib()

There are even convenient ways to add event handlers:

// Hide when button tapped
messageView.buttonTapHandler = { _ in SwiftMessages.hide() }

// Hide when message view tapped
messageView.tapHandler = { _ in SwiftMessages.hide() }

It's very cool. Why re-invent the wheel?



-->
ALEXANDER
PATERSON