Skip to content

paoloandrea/ToastView

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

20 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ToastView 2.0 🍞

Easily display toast messages with optional icons, progress indicators, and stunning Liquid Glass effects in your iOS and tvOS apps.

Screenshot of ToastView

Features

  • 🌟 Display simple toast messages or toasts with icons.
  • πŸ”„ Optional progress indicator for toasts that represent a loading state.
  • ✨ Liquid Glass effect on iOS 26+ / tvOS 26+ with automatic fallback to blur on older versions.
  • πŸŒ“ Automatic dark mode and light mode support.
  • 🌌 Optional blurred/glass background to overlay entire application.
  • πŸ“± Full support for iOS 13+ and tvOS 13+.
  • πŸ“ 7 customizable toast display positions (topLeft, top, topRight, center, bottomLeft, bottom, bottomRight).
  • πŸ”€ Multi-line message support.
  • 🎯 Multiple toasts support with smart positioning.
  • πŸ“Š Smart TabBar detection: Automatically positions bottom toasts above the UITabBarController when present (16px spacing).

Requirements

  • iOS 13.0+ / tvOS 13.0+
  • Xcode 15.0+
  • Swift 5.9+

Installation

Swift Package Manager

Add ToastView to your project via Swift Package Manager:

dependencies: [
    .package(url: "https://github.com/paoloandrea/ToastView.git", from: "2.0.0")
]

Manual

  1. Download the ToastManager.swift and ToastView.swift files from this repository.
  2. Add them to your Xcode project.

Usage

  1. Basic Toast Since ToastManager is a singleton, you do not instantiate it directly. Instead, you access the shared instance as follows:
let toastManager = ToastManager.shared
toastManager.showToast(
    message: "Your message here",
    image: UIImage(named: "your_image_name"),
    isProgress: false,
    position: .center,
    duration: 2.0,
    in: yourView,
    withBackground: true)
  1. Toast with Icon
    let image = UIImage(systemName: "star.fill")
    toastManager.showToast(message: "Starred", image: image, position: .top)
  1. Toast with Progress Indicator
    toastManager.showToast(message: "Loading...", isProgress: true, position: .bottom)
  1. Toast with Blurred Background Overlay
    toastManager.showToast(message: "Blurred Background", position: .center, withBackground: true)
  1. Dismiss Toast Manually
    toastManager.cancelCurrentToast()
  1. Dismiss Toast After a Delay
    DispatchQueue.main.asyncAfter(deadline: .now() + 3.0) {
        toastManager.cancelCurrentToast()
    }

Advanced Features

Update Toast Message

Update the message of the current toast without creating a new one:

toastManager.message = "Updated message"

Multiple Toasts

Enable multiple toasts to stack vertically:

toastManager.allowMultipleToasts = true
toastManager.showToast(message: "First toast", position: .top)
toastManager.showToast(message: "Second toast", position: .top)

Toast Positions

Available positions:

  • Standard positions: .topLeft, .top, .topRight, .center, .bottomLeft, .bottom, .bottomRight
  • Forced above TabBar: .bottomLeftAboveTabBar, .bottomAboveTabBar, .bottomRightAboveTabBar

Smart TabBar Detection

ToastView offers two modes for handling tab bars:

Automatic Detection (Default)

When displaying toasts at bottom positions (.bottom, .bottomLeft, .bottomRight), ToastView automatically detects if a UITabBarController is present in the view hierarchy. If a visible tab bar is found, the toast will be positioned 16px above the tab bar.

// Automatic detection - positions above tab bar if present
toastManager.showToast(message: "Auto-positioned toast", position: .bottom)

Manual Control

For explicit control, use the dedicated "AboveTabBar" positions (.bottomAboveTabBar, .bottomLeftAboveTabBar, .bottomRightAboveTabBar). These positions always place the toast above the standard tab bar height, even if no tab bar is detected.

// Always positions above tab bar area (even without UITabBarController)
toastManager.showToast(message: "Forced above tab bar", position: .bottomAboveTabBar)

Note: Automatic detection works when:

  • A UITabBarController exists in the view hierarchy
  • The tab bar is visible (not hidden)

The manual positions use a fallback height (49px + 16px spacing) when no tab bar is detected.

Visual Effects

Liquid Glass Effect (iOS 26+ / tvOS 26+)

On iOS 26 and tvOS 26 or later, ToastView automatically uses the stunning Liquid Glass effect (UIGlassEffect) for a modern, translucent appearance. On older versions, it gracefully falls back to UIBlurEffect.

Dark Mode Support

ToastView automatically adapts to the system's light/dark mode appearance using semantic colors and adaptive materials.

Configuration Options

  • allowMultipleToasts: Set to true to allow showing multiple toasts at once (default: false).
  • message: Update the current toast message without recreating the toast.
  • duration: Set to 0 for indefinite display, or specify seconds for auto-dismiss.
  • withBackground: Add a blurred/glass overlay behind the toast.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT License - see LICENSE for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages