Toast

class Toast

Display a toast message in a label for a few seconds and dissapears

Usage:

 Toast.regular("My message") // It accepts delay in seconds and position (.top, .center .bottom)

 // There are .info, .warning, .error and .success toasts.
 Toast.info("My message", position: .top, delay: 10)

Originally extracted from https://stackoverflow.com/questions/31540375/how-to-create-a-toast-message-in-swift

  • Short delay

    Declaration

    Swift

    static let kDelayShort: Double
  • Long delay

    Declaration

    Swift

    static let kDelayLong: Double
  • Background opacity

    Declaration

    Swift

    static let kBackgroundOpacity: Double
  • height of the toast

    Declaration

    Swift

    static let kToastHeight: Int
  • withd of the toast

    Declaration

    Swift

    static let kToastWidth: Int
  • Offset from the closest screen edge (top or bottom).

    Declaration

    Swift

    static let kToastOffset: Int
  • Font size of the toast

    Declaration

    Swift

    static let kFontSize: Int
  • Toast.regular text color

    Declaration

    Swift

    static let kRegularTextColor: UIColor
  • Toast.regular background color

    Declaration

    Swift

    static let kRegularBackgroundColor: UIColor
  • Toast.info text color

    Declaration

    Swift

    static let kInfoTextColor: UIColor
  • Toast.info background color

    Declaration

    Swift

    static let kInfoBackgroundColor: UIColor
  • Toast.success text color

    Declaration

    Swift

    static let kSuccessTextColor: UIColor
  • Toast.success background color

    Declaration

    Swift

    static let kSuccessBackgroundColor: UIColor
  • Toast.warning text color

    Declaration

    Swift

    static let kWarningTextColor: UIColor
  • Declaration

    Swift

    static let kWarningBackgroundColor: UIColor
  • Toast.error text color

    Declaration

    Swift

    static let kErrorTextColor: UIColor
  • Toast.error background color

    Declaration

    Swift

    static let kErrorBackgroundColor: UIColor
  • Position of the toast in the vertical access

    See more

    Declaration

    Swift

    enum Position
  • Generic implementation to show toast

    Declaration

    Swift

    static func showToast(_ message: String, textColor: UIColor, backgroundColor: UIColor, position: Position, delay: Double)

    Parameters

    message

    Text message to display

    textColor

    Color of the text

    backgroundColor

    Color of the text

    position

    Position within the screen (.bottom, .center, .top)

    delay

    time in seconds that the toast will be displayed

  • Displays a regular toast (black)

    See also

    SeeAlso showToast

    Declaration

    Swift

    class func regular(_ message: String, position: Position = Position.bottom, delay: Double = kDelayLong)
  • Information toast (blue)

    See also

    SeeAlso showToast

    Declaration

    Swift

    class func info(_ message: String, position: Position = Position.bottom, delay: Double = kDelayLong)
  • Display a warning toast (orange)

    See also

    SeeAlso showToast

    Declaration

    Swift

    class func warning(_ message: String, position: Position = Position.bottom, delay: Double = kDelayLong)
  • Display a Success toast

    See also

    SeeAlso showToast

    Declaration

    Swift

    class func success(_ message: String, position: Position = Position.bottom, delay: Double = kDelayLong)
  • Display a error toast

    See also

    SeeAlso showToast

    Declaration

    Swift

    class func error(_ message: String, position: Position = Position.bottom, delay: Double = kDelayLong)