CreationKit Documentation

Class Snackbar

public final class Snackbar  

Snackbars inform users of a process that an app has performed or will perform.

They appear temporarily, towards the bottom of the screen. They shouldn’t interrupt the user experience, and they don’t require user input to disappear.

Methods

show(message:​duration:​style:​presentation​Context:​button​Title:​button​Action:​)

public static func show(message: String,
                          duration: BannerDuration = .short,
                          style: BannerStyle = .default,
                          presentationContext: SnackbarPresentationContext = .automatic,
                          buttonTitle: String? = nil,
                          buttonAction: ((UIButton) -> Void)? = nil)  

Displays the Snackbar.

Parameters

message String

The message to display.

duration Banner​Duration

The duration the snackbar stays on screen.

style Banner​Style

The Style to display the snackbar in.

presentation​Context Snackbar​Presentation​Context

The presentation context to display in. Defaults to .automatic. You should only change this in cases where automatic has a hard time displaying the snackbar correctly, e.g MessagesViewController.

button​Title String?

The button title if any. Leave as nil if you don't want a button to be displayed.

button​Action ((UIButton) -> Void)?

The closure that will be called when the button is tapped. Defaults to nil.