A Swift extension that adds toast notifications to the UIView object class.

Overview

Toast-Swift

Build Status CocoaPods Version Carthage Compatible

Toast-Swift is a Swift extension that adds toast notifications to the UIView object class. It is intended to be simple, lightweight, and easy to use. Most toast notifications can be triggered with a single line of code.

Toast-Swift is a native Swift port of Toast for iOS.

Screenshots

Toast-Swift Screenshots

Basic Examples

// basic usage
self.view.makeToast("This is a piece of toast")

// toast with a specific duration and position
self.view.makeToast("This is a piece of toast", duration: 3.0, position: .top)

// toast presented with multiple options and with a completion closure
self.view.makeToast("This is a piece of toast", duration: 2.0, point: CGPoint(x: 110.0, y: 110.0), title: "Toast Title", image: UIImage(named: "toast.png")) { didTap in
    if didTap {
        print("completion from tap")
    } else {
        print("completion without tap")
    }
}

// display toast with an activity spinner
self.view.makeToastActivity(.center)

// display any view as toast
self.view.showToast(myView)

// immediately hides all toast views in self.view
self.view.hideAllToasts()

But wait, there's more!

// create a new style
var style = ToastStyle()

// this is just one of many style options
style.messageColor = .blue

// present the toast with the new style
self.view.makeToast("This is a piece of toast", duration: 3.0, position: .bottom, style: style)

// or perhaps you want to use this style for all toasts going forward?
// just set the shared style and there's no need to provide the style again
ToastManager.shared.style = style
self.view.makeToast("This is a piece of toast") // now uses the shared style

// toggle "tap to dismiss" functionality
ToastManager.shared.isTapToDismissEnabled = true

// toggle queueing behavior
ToastManager.shared.isQueueEnabled = true

See the demo project for more examples.

Setup Instructions

CocoaPods

To integrate Toast-Swift into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'Toast-Swift', '~> 5.0.1'

and in your code add import Toast_Swift.

Carthage

To integrate Toast-Swift into your Xcode project using Carthage, specify it in your Cartfile:

github "scalessec/Toast-Swift" ~> 5.0.1

Run carthage update to build the framework and drag the built ToastSwiftFramework.framework into your Xcode project.

and in your code add import ToastSwiftFramework.

Swift Package Manager

When using Xcode 11 or later, you can install Toast by going to your Project settings > Swift Packages and add the repository by providing the GitHub URL. Alternatively, you can go to File > Swift Packages > Add Package Dependencies...

Manually

  1. Add Toast.swift to your project.
  2. Grab yourself a cold 🍺 .

Compatibility

  • Version 5.x.x requires Swift 5 and Xcode 10.2 (or newer versions of Xcode).
  • Version 4.x.x requires Swift 4.2 and Xcode 10.
  • Version 3.x.x requires Swift 4 and Xcode 9.
  • Version 2.x.x requires Swift 3 and Xcode 8.
  • Version 1.4.x requires Swift 2.2 and Xcode 7.3.
  • Version 1.0.0 can be used with Swift 2.1 and earlier versions of Xcode.

MIT License

Copyright (c) 2015-2019 Charles Scalesse.

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Comments
  • Swift 4 XCode 9

    Swift 4 XCode 9

    • 2 issues in this pod.
    • Can't use it anymore.

    1- Argument of '#selector' refers to instance method 'toastTimerDidFinish' that is not exposed to Objective-C 2- Argument of '#selector' refers to instance method 'handleToastTapped' that is not exposed to Objective-C

    Can you please tell when 3.0.0 will be available ? Thanks for your good work :)

    opened by BurhanMughal 11
  • Tag 2.0.0 is missing from CocoaPods

    Tag 2.0.0 is missing from CocoaPods

    Version 2.0.0 is missing from CocoaPods, due to issues related to CocoaPods and Xcode8. As of today, pod lib lint fails and therefore 2.0.0 can't be published.

    This is the same issue: https://github.com/CocoaPods/CocoaPods/issues/5663

    And that issue has this cause: https://github.com/CocoaPods/CocoaPods/issues/5661

    This should be fixed when the next version of Cocoapods is released.

    opened by scalessec 10
  • Not arm64 compliant

    Not arm64 compliant

    "type metadata for (extension in myproject):__ObjC.UIView.(ToastError in _9435D8AD737309FD1AA87C6149FEA121)", referenced from:

    ld: symbol(s) not found for architecture arm64

    cant compile it on arm64 architecture.

    opened by San-Jeevan 6
  • Toast showing mode

    Toast showing mode

    Hello ! I've been using the framework at work, and I really like it, but I run into the issue that I needed it to hide a toast programmatically and there was no possibility for that. There is a private hide toast method; is there any particular reason why you decided to make it private, or just didn't feel the need to make it public?

    The situation was that we didn't want a queue of toasts and neither toasts overlapping. I think it would be great to have a "mode" were you can choose from queue, "normal" (showing one on top of the other) and "unique" (a view can show one toast at a time). I think it could be done, for example, by storing in the view the lastToast shown (as a UIView?) and hide the lastToast before showing a new one and updating the property.

    But apart from having a mode option for unique toast showing, I think having the public hideToast method can give the programmer more flexibility for the exceptional case they run into.

    What do you think?

    opened by danielaRiesgo 6
  • Enable toast top/bottom offset

    Enable toast top/bottom offset

    Sometimes I need to set a bottom offset for the toast.

    https://github.com/devxoul/Toaster has a pretty nice bottomOffsetPortrait/bottomOffsetLandscape settings.

    It will be nice to have this feature.

    opened by everwanna 5
  • Cocoapod Migration

    Cocoapod Migration

    Working on my new release I have modified my podfile to request the Swift 3 branch. After running pod install, Xcode attempts to migrate Toast.swift to use the new access control identifiers "open" and "fileprivate".

    opened by dpfannenstiel 5
  • Swift: Positioning Toast on status bar, navigation bar, other

    Swift: Positioning Toast on status bar, navigation bar, other

    Seems that the only ToastPositions are .Top, .Center, and .Bottom or a specific CGPoint can be used.

    If one would like to position a toast in a particular area, for example in place of the status bar or over the navigation bar, how can one do so?

    opened by dnadri 5
  • Pod install use_frameworks!

    Pod install use_frameworks!

    Installing Toast-Swift via Cocoapods results in errors.

    This is the module Toast_Swift after installing with use_frameworks! needed for Swift

    import ObjectiveC
    import Toast_Swift
    import Toast_Swift.Swift
    import UIKit
    
    public var Toast_SwiftVersionNumber: Double
    

    As you can see the module references itself...

    Is this a bug or am I doing something wrong?

    opened by OliverZiegler 5
  • SwiftPM still Not working

    SwiftPM still Not working

    I put below the repository also still I'm getting the same issues. check be below screen shots. Kindly do needfully

    Screenshot 2020-06-29 at 5 16 32 PM

    "https://github.com/scalessec/Toast-Swift.git"

    Originally posted by @syedrazackimran in https://github.com/scalessec/Toast-Swift/issues/165#issuecomment-651063128

    opened by syedrazackimran 4
  • Updated project for Xcode 10.2 & Swift 5

    Updated project for Xcode 10.2 & Swift 5

    I've solved the warnings that are presented in Xcode 10.2 and upgraded the projects settings to Swift 5.

    Also referenced in issue https://github.com/scalessec/Toast-Swift/issues/137

    opened by ppeelen 4
  • .swift-version not in 4.2

    .swift-version not in 4.2

    Hello,

    There is a small issue in your .swift-version file (https://github.com/scalessec/Toast-Swift/blob/master/.swift-version). It does not indicate v4.2 whereas the pod uses swift 4.2.

    Cocoapods relies on this file for the SWIFT_VERSION flag. That creates issues when building this pod as a dependency with Xcode 10.

    Thank you!

    opened by JohanDufau 4
  • BitCode

    BitCode

    I am using a lot of Swift Packages, some of them through warning if bitcode is not enabled in the Setting. Can someone recompile the Package with Bitcode enabled?

    Thx

    opened by phil16727 0
  • Toast should move up with keyboard

    Toast should move up with keyboard

    Showing a toast on the main view of a controller makes it invisible if keyboard is showing. Should account for keyboard height and move it if the keyboard is showing and move back down once closed.

    opened by shadowpath 0
  • Multiple are not working its showing only one line.

    Multiple are not working its showing only one line.

    i am able to use for one line messages but not for multiple line. var style = ToastStyle() style.messageColor = .white style.backgroundColor = .darkGray style.maxHeightPercentage = 1.0 style.maxWidthPercentage = 0.9 style.horizontalPadding = 10.0 style.messageAlignment = .center style.messageNumberOfLines = 2 style.displayShadow = true

        style.messageFont = UIFont.systemFont(ofSize: 14, weight: .regular)
        style.messageNumberOfLines = 0
        self.view.makeToast("\(string)", duration: 2.0, position: .bottom, title: nil, image: nil, style: style)
        ToastManager.shared.isTapToDismissEnabled = false
        ToastManager.shared.isQueueEnabled = true
    
    opened by SanaboinaPrasad 0
Owner
Charles Scalesse
Charles Scalesse
CoffeeToast - A swift package to easily add Toast notifications to your app

CoffeeToast A simple Swift package to add Toast Notifications to your app. Insta

Maegan Wilson 2 Feb 3, 2022
LCToast - Add toast to UIView.

LCToast Add toast to UIView. Requirements iOS 8.0+ Features The LCToast is a comparison of features with Toast and SVProgressHUD. LCToast Toast SVProg

LiuChang 158 Nov 22, 2022
A Swift Toast view - iOS 14 style and newer - built with UIKit. 🍞

Toast-Swift A Swift Toast view - iOS 14 style - built with UIKit. ?? Installation Swift Package Manager You can use The Swift Package Manager to insta

Bastiaan Jansen 216 Jan 4, 2023
🍞 Toast for Swift

Toaster Android-like toast with very simple interface. (formerly JLToast) Screenshots Features Queueing: Centralized toast center manages the toast qu

Suyeol Jeon 1.6k Dec 30, 2022
A modern iOS toast view that can fit your notification needs

CRToast CRToast is a library that allows you to easily create notifications that appear on top of or by pushing out the status bar or navigation bar.

Collin Ruffenach 4.2k Dec 30, 2022
A Simple Toast Library for iOS

PowerplayToastKit Toasts Type Success. Warning Error Info Custom View (Dialog) Example To run the example project, clone the repo, and run pod install

Mithilesh Parmar 18 Jul 2, 2022
Bulletin / 'Toast' style view for tvOS.

KBBulletinView Bulletin / 'Toast' style view for tvOS. This project is an effort to create local application notifications/alerts similar to those use

Kevin Bradley 4 Nov 26, 2022
A simple style messages/notifications, in Swift.

Demo Example To show notifications use the following code: self.showMessage("Something success", type: .success) To display a notice on a view: view.s

Gesen 704 Dec 17, 2022
SwiftOverlays is a Swift GUI library for displaying various popups and notifications

SwiftOverlays is a Swift GUI library for displaying various popups and notifications. SwiftOverlays animated logo is kindly made by Crafted Pixels Fea

Peter Prokop 632 Dec 22, 2022
Simple Swift in-app notifications

LNRSimpleNotifications TSMessages is an amazingly powerful in-app notifications library but requires a lot of setup. LNRSimpleNotifications is a simpl

LISNR 203 Nov 20, 2022
πŸ’Œ Easy to use and customizable messages/notifications for iOS Γ  la Tweetbot

Notice: TSMessages is no longer being maintained/updated. We recommend everyone migrate to RMessage. This repository will be kept as is for those who

Felix Krause 4.9k Dec 31, 2022
[iOS] Easy, customizable notifications displayed on top of the statusbar. With progress and activity. iPhone X ready.

JDStatusBarNotification Show messages on top of the status bar. Customizable colors, font and animation. Supports progress display and can show an act

M Emrich 3.8k Dec 27, 2022
Whisper is a component that will make the task of display messages and in-app notifications simple. It has three different views inside

Description ?? Break the silence of your UI, whispering, shouting or whistling at it. Whisper is a component that will make the task of displaying mes

HyperRedink 3.7k Dec 25, 2022
This is a small View modifier that adds detents for native .sheet representations that appeared in iOS 16

SheetDetentsModifier This is a small View modifier that adds detents for .sheet representations that appeared in iOS 16 It works starting with iOS 15

Alex Artemev 19 Oct 9, 2022
This is an iOS control for presenting any UIView in an UIAlertController like manner

RMActionController This framework allows you to present just any view as an action sheet. In addition, it allows you to add actions around the present

Roland Moers 542 Dec 5, 2022
Simple UIAlertController builder class in Swift.

Kamagari Simple UIAlertController builder class in Swift. Features AlertBuilder class to simply build UIAlertController by using method chaining UIAle

Kazunobu Tasaka 78 Nov 29, 2022
an extension library for SwiftUI sheets.

SheetKit SheetKit is an extension library for SwiftUI sheets. δΈ­ζ–‡η‰ˆθ―΄ζ˜Ž with Picture What is SheetKit SheetKit is a library of extensions for SwiftUI moda

δΈœε‘θ‚˜ε­ 65 Dec 31, 2022
DataDrivenAlert - Extension for SwiftUI.Alert for data driven configuration

Data driven alert and confirmation dialog Based on Composable Architecture Alert

Evgeny 2 Apr 9, 2022
πŸ’¬ A tiny extension for UIAlertController that makes working with it very simple. Only 150 lines of code.

AlertController ?? A tiny extension for UIAlertController that makes working with it very simple. Only 150 lines of code. Alert let alert = UIAlertCon

Mezhevikin Alexey 9 Nov 2, 2022