Class
Banner
public final class Banner
A banner displays a prominent message and related optional actions.
Banners, like Snackbars, appear temporarily, inform the user of an undertaken action, do not interrupt the user experience, and do not require user input. The primary difference is that they are displayed toward the top of the device.
Methods
makeView(message:style:buttonTitle:buttonAction:)
public static func makeView(
message: String,
style: BannerStyle = .default,
buttonTitle: String? = nil,
buttonAction: ((UIButton) -> Void)? = nil
) -> BannerViewable
show(message:duration:style:presentationContext:buttonTitle:buttonAction:)
public static func show(
message: String,
duration: BannerDuration = .short,
style: BannerStyle = .default,
presentationContext: BannerPresentationContext = .automatic,
buttonTitle: String? = nil,
buttonAction: ((UIButton) -> Void)? = nil
)
Displays the Banner.
Parameters
Name | Type | Description |
---|---|---|
message | String |
The message to display. |
duration | BannerDuration |
The duration the snackbar stays on screen. |
style | BannerStyle |
The Style to display the snackbar in. |
presentationContext | BannerPresentationContext |
Use this parameter to specify the scope (window, view controller, view) a banner should appear in. Default is |
buttonTitle | String? |
The button title if any. Leave as nil if you don't want a button to be displayed. |
buttonAction | ((UIButton) -> Void)? |
The closure that will be called when the button is tapped. Defaults to nil. |
showTappable(attributedMessage:tappableTextColor:dataDetectorTypes:duration:style:presentationStyle:presentationContext:shouldHideAfterTap:hasShadow:textTapHandler:)
public static func showTappable(
attributedMessage: NSAttributedString,
tappableTextColor: UIColor? = nil,
dataDetectorTypes: UIDataDetectorTypes = .all,
duration: BannerDuration = .short,
style: BannerStyle = .default,
presentationStyle: SwiftMessages.PresentationStyle = .top,
presentationContext: BannerPresentationContext = .automatic,
shouldHideAfterTap: Bool = true,
hasShadow: Bool = true,
textTapHandler: ((String) -> Void)? = nil
)
Displays the Banner with a tappable text portion. This tappable text can be a detectable type, such as a phone number; or the tappable portion can be regular text that has a text tap handler.
Parameters
Name | Type | Description |
---|---|---|
attributedMessage | NSAttributedString |
The message to display. Attributes such as font and text color should be set in the NSAttributedString's attributes. |
tappableTextColor | UIColor? |
Optional color for setting the tappable text's color. This setter is for convenience if the tappable text color is not set using NSAttributedString's attributes. Default is |
dataDetectorTypes | UIDataDetectorTypes |
The types of information to detect in the banner. |
duration | BannerDuration |
The duration the banner stays on screen. |
style | BannerStyle |
The Style to display the banner in. |
presentationStyle | SwiftMessages.PresentationStyle |
The PresentationStyle to specify whether the banner will be presented at top or bottom of the selected presentation container. |
presentationContext | BannerPresentationContext |
Use this parameter to specify the scope (window, view controller, view) a banner should appear in. Default is |
shouldHideAfterTap | Bool |
Will hide banner after text is tapped. Default is true. |
textTapHandler | ((String) -> Void)? |
The closure that will be called when the text is tapped. Defaults to nil. |
makeTappableView(attributedMessage:tappableTextColor:dataDetectorTypes:style:shouldHideAfterTap:hasShadow:textTapHandler:)
public static func makeTappableView(
attributedMessage: NSAttributedString,
tappableTextColor: UIColor? = nil,
dataDetectorTypes: UIDataDetectorTypes = .all,
style: BannerStyle = .default,
shouldHideAfterTap: Bool = true,
hasShadow: Bool = true,
textTapHandler: ((String) -> Void)? = nil ) -> BannerViewable