BPKToast
@interface BPKToast : UIView
BPKToast
is a subclass of UIView
configured with Skyscanner style properties.
-
BPKToast operation mode. The default is BPKToastModeIndeterminate.
See
BPKToastModeDeclaration
Objective-C
@property (nonatomic) BPKToastMode mode;
Swift
var mode: BPKToastMode { get set }
-
The minimum time (in seconds) that the Toast is shown. This avoids the problem of the Toast being shown and than instantly hidden. Defaults to 0 (no minimum show time).
Declaration
Objective-C
@property float minShowTime;
Swift
var minShowTime: Float { get set }
-
An optional short message to be displayed below the activity indicator. The Toast is automatically resized to fit the entire text. If the text is too long it will get clipped by displaying “…” at the end. If left unchanged or set to @“”, then no message is displayed.
Declaration
Objective-C
@property (nonatomic, copy) NSString *_Nonnull labelText;
Swift
var labelText: String { get set }
-
An optional details message displayed below the labelText message. This message is displayed only if the labelText property is also set and is different from an empty string (@“”). The details text can span multiple lines.
Declaration
Objective-C
@property (nonatomic, copy) NSString *_Nonnull detailsLabelText;
Swift
var detailsLabelText: String { get set }
-
Removes the Toast from its parent view when hidden. Defaults to NO.
Declaration
Objective-C
@property (nonatomic) BOOL removeFromSuperViewOnHide;
Swift
var removeFromSuperViewOnHide: Bool { get set }
-
Creates a new Toast, adds it to provided view and shows it.
Note
This method sets
removeFromSuperViewOnHide
. The Toast will automatically be removed from the view hierarchy when hidden.Declaration
Objective-C
+ (nonnull instancetype)showToastAddedTo:(nonnull UIView *)view animated:(BOOL)animated;
Swift
class func showAdded(to view: UIView, animated: Bool) -> Self
Parameters
view
The view that the Toast will be added to
animated
If set to YES the Toast will appear using the current animationType. If set to NO the Toast will not use animations while appearing.
Return Value
A reference to the created Toast.
-
A convenience constructor that initializes the Toast with the view’s bounds. Calls the designated constructor with view.bounds as the parameter
Declaration
Objective-C
- (nonnull instancetype)initWithView:(nonnull UIView *)view;
Swift
init(view: UIView)
Parameters
view
The view instance that will provide the bounds for the Toast. Should be the same instance as the Toast’s superview (i.e., the view that the Toast will be added to).
-
Display the Toast. You need to make sure that the main thread completes its run loop soon after this method call so the user interface can be updated. Call this method when your task is already set-up to be executed in a new thread (e.g., when using something like NSOperation or calling an asynchronous call like NSURLRequest).
Declaration
Objective-C
- (void)show:(BOOL)animated;
Swift
func show(_ animated: Bool)
Parameters
animated
If set to YES the Toast will appear using the current animationType. If set to NO the Toast will not use animations while appearing.
-
Hide the Toast. This is the counterpart of the show: method. Use it to hide the Toast when your task completes.
Declaration
Objective-C
- (void)hide:(BOOL)animated;
Swift
func hide(_ animated: Bool)
Parameters
animated
If set to YES the Toast will disappear using the current animationType. If set to NO the Toast will not use animations while disappearing.
-
Hide the Toast after a delay. This is the counterpart of the show: method. Use it to hide the Toast when your task completes.
Declaration
Objective-C
- (void)hide:(BOOL)animated afterDelay:(NSTimeInterval)delay;
Swift
func hide(_ animated: Bool, afterDelay delay: TimeInterval)
Parameters
animated
If set to YES the Toast will disappear using the current animationType. If set to NO the Toast will not use animations while disappearing.
delay
Delay in seconds until the Toast is hidden.