FUIToastMessage
public class FUIToastMessage
FUIToastMessage
provides convenience class methods for showing an overlay toast-type message centered on screen.
Only one message can be visible at the same time and the FUIToastMessage
class makes sure that previous messages
are properly dismissed before the next is shown.
You use the show()
method to display messages. By default, the toast message is shown for one second but applications can
change that duration.
Note
A toast message is meant to be used for short messages and is limited to one line of text by default. This can be changed by applications by setting themaxNumberOfLines
parameter to another value.
Usage
Show Fullscreen
FUIToastMessage.show(message: "This is a message")
Show Fullscreen with Custom Duration
FUIToastMessage.show(message: "This is a message", withDuration: 3)
-
Shows the toast message in the center of the screen with a given duration. This method dispatches all UIKit drawing back to the main thread, so it is safe to call it from a background thread.
Only one message can be visible at the same time. If
show(message: String)
is called while another message is visible the first one is dismissed.Declaration
Swift
public class func show(message: String, icon: UIImage = FUIIconLibrary.system.success.withRenderingMode(.alwaysTemplate), inWindow window: UIWindow? = nil, withDuration duration: Float = 1.0, maxNumberOfLines lines: Int = 1)
-
Shows the toast message in the center of the given container view with a given duration. This method dispatches all UIKit drawing back to the main thread, so it is safe to call it from a background thread.
Declaration
Swift
public class func show(message: String, icon: UIImage = FUIIconLibrary.system.success.withRenderingMode(.alwaysTemplate), inView view: UIView, withDuration duration: Float = 1.0, maxNumberOfLines lines: Int = 1)
Parameters
message
the text of the toast message.
icon
the icon in front of the text. The default is a checkmark icon.
inView
the container view in which to display the toast message. The toast message will be shown centered in the container.
duration
the duration in seconds for which the toast message is shown. The default is
1
.lines
maximum number of lines the text message can have. The default is
1
. A value of0
does not restrict the number of lines at all.