A Swift Toast view - iOS 14 style - built with UIKit.


Swift Package Manager

You can use The Swift Package Manager to install Toast-Swift by adding the description to your Package.swift file:

dependencies: [
    .package(url: "", from: "1.0.3")


pod "ToastViewSwift"


To create a simple text based toast:

let toast = Toast.text("Safari pasted from Notes")

Or add a subtitle:

let toast = Toast.text("Safari pasted from Notes", subtitle: "A few seconds ago")

If you want to add an icon, use the default method to construct a toast:

let toast = Toast.default(
    image: UIImage(systemname: "airpodspro")!,
    title: "Airpods Pro",
    subtitle: "Connected"

Want to use a different layout, but still use the Apple style? Create your own view and inject it into the AppleToastView class when creating a custom toast:

let customView: UIView = // Custom view

let appleToastView = AppleToastView(child: customView)

let toast = Toast.custom(view: appleToastView)

The show method accepts several optional parameters. haptic of type UINotificationFeedbackGenerator.FeedbackType to use haptics and after of type TimeInterval to show the toast after a certain amount of time: .success, after: 1)

Configuration options

The text, default and custom methods support custom configuration options. The following options are available:

Name Description Type Default
autoHide When set to true, the toast will automatically close itself after display time has elapsed. Bool true
displayTime The duration the toast will be displayed before it will close when autoHide set to true. TimeInterval 4
animationTime Duration of the show and close animation. TimeInterval 0.2
attachTo The view which the toast view will be attached to. UIView nil
let config = ToastConfiguration(
    autoHide: true,
    displayTime: 5,
    animationTime: 0.2

let toast = toast.text("Safari pasted from Notes", config: config)

Custom toast view

Don't like the default Apple'ish style? No problem, it is also possible to use a custom toast view with the custom method. Firstly, create a class that confirms to the ToastView protocol:

class CustomToastView : UIView, ToastView {
    private let text: String

    public init(text: String) {
        self.text = text

    func createView(for toast: Toast) {
        // View is added to superview, create and style layout and add constraints

Use your custom view with the custom construct method on Toast:

let customToastView: ToastView = CustomToastView(text: "Safari pasted from Notes")

let toast = Toast.custom(view: customToastView)