It's quite common to need to display short status messages or notifications inside our apps. Today we'll look at a library called Whisper that is absolutely packed with features that make displaying these types of messages both simple and beautiful. Let's dive in.
Whisper provides 3 different types of display styles. All allow for extensive customization including colors, fonts, etc.
First up is "Whispering" a Message:
let message = Message(
title: "π¨ Imperial Troops Have Entered the Base!",
color: .redColor()
)
Whisper(message, to: navigationController, action: .Present)
Silent(navigationController, after: 3)
We call the Silent function right after we present the Whisper, this will dismiss the message after 3 seconds.
Next, let's try "Shouting" an Announcement.
This one's great for longer text, and looks great with an image. We can also pass in an closure to run when the user taps the banner.
let announcement = Announcement(
title: "Han Solo Says:",
subtitle: "Who's scruffy lookin'?!",
image: UIImage(named: "avatar")
)
Shout(announcement, to: self)
Lastly, we can "Whistle" a Murmur to display a subtle, classy message in the status bar:
let murmur = Murmur(title: "The last transport... is away! π", backgroundColor: murmurColor)
Whistle(murmur)
More info about Whisper can be found at git.io/whisper