MDCSnackbarMessage

@interface MDCSnackbarMessage
    : NSObject <NSCopying, UIAccessibilityIdentification>

Represents a message to unobtrusively show to the user.

A Snackbar message provides brief feedback about an operation. Messages are passed to the Snackbar manager to be displayed.

Snackbars prefer an application’s main window is a subclass of @c MDCOverlayWindow. When a standard UIWindow is used an attempt is made to find the top-most view controller in the view hierarchy.

  • Returns a MDCSnackbarMessage with its text initialized.

    Declaration

    Objective-C

    + (nonnull instancetype)messageWithText:(nonnull NSString *)text;

    Parameters

    text

    The text to display in the message.

    Return Value

    An initialized MDCSnackbarMessage object with @c text.

  • Returns a MDCSnackbarMessage with its attributed text initialized.

    Declaration

    Objective-C

    + (nonnull instancetype)messageWithAttributedText:
        (nonnull NSAttributedString *)attributedText;

    Parameters

    attributedText

    The attributed text to display in the message.

    Return Value

    An initialized MDCSnackbarMessage object with @c attributedText.

  • Use the older legacy version of Snackbar. Default is YES.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, class) BOOL usesLegacySnackbar;
  • The primary text of the message.

    Either @c text or @c attributedText must be set.

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic, nullable) NSString *text;
  • The primary text of the message with styling.

    Any attributes supported by UIKit may be set, though font and color will be overridden by the Snackbar. Either @c text or @c attributedText must be set.

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic, nullable)
        NSAttributedString *attributedText;
  • Optional button to show along with the rest of the message.

    A MDCSnackbarMessageAction is displayed as a button on the Snackbar. If no action is set no button will appear on the Snackbar.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, nullable)
        MDCSnackbarMessageAction *action;
  • The color used for button text on the Snackbar in normal state.

    Default is nil, but MDCRGBAColor(0xFF, 0xFF, 0xFF, (CGFloat)0.6) will be set as the default color and is taken from MDCSnackbarMessageView’s buttonTitleColorForState:

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, nullable) UIColor *buttonTextColor;
  • How long the message should be displayed.

    Defaults to 4 seconds and can be set up to the maximum duration defined by @c MDCSnackbarMessageDurationMax. Any value set above this limit will use the maximum duration.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) NSTimeInterval duration;
  • Called when a message is finished displaying.

    The message completion handler is called regardless of whether or not buttons were tapped and is always called on the main thread.

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic, nullable)
        MDCSnackbarMessageCompletionHandler completionHandler;
  • The category of messages to which a message belongs.

    Default is nil. If set, only the last message of this category will be shown, any currently showing or pending messages in this category will be dismissed as if the user had directly tapped the Snackbar.

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic, nullable) NSString *category;
  • Redeclaration from UIAccessibility to make clear that this class supports accessibility labels.

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic, nullable) NSString *accessibilityLabel;
  • Redeclaration from UIAccessibility to make clear that this class supports accessibility hints.

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic, nullable) NSString *accessibilityHint;
  • Text that should be read when the message appears on screen and VoiceOver is enabled.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) NSString *voiceNotificationText;