4 [![Build Status](https://travis-ci.org/scalessec/Toast-Swift.svg?branch=master)](https://travis-ci.org/scalessec/Toast-Swift)
5 [![CocoaPods Version](https://img.shields.io/cocoapods/v/Toast-Swift.svg)](http://cocoadocs.org/docsets/Toast-Swift)
6 [![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
8 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.
10 **Toast-Swift is a native Swift port of [Toast for iOS](https://github.com/scalessec/Toast "Toast for iOS").**
14 ![Toast-Swift Screenshots](toast_swift_screenshot.jpg)
21 self.view.makeToast("This is a piece of toast")
23 // toast with a specific duration and position
24 self.view.makeToast("This is a piece of toast", duration: 3.0, position: .top)
26 // toast presented with multiple options and with a completion closure
27 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
29 print("completion from tap")
31 print("completion without tap")
35 // display toast with an activity spinner
36 self.view.makeToastActivity(.center)
38 // display any view as toast
39 self.view.showToast(myView)
41 // immediately hides all toast views in self.view
42 self.view.hideAllToasts()
45 But wait, there's more!
49 var style = ToastStyle()
51 // this is just one of many style options
52 style.messageColor = .blue
54 // present the toast with the new style
55 self.view.makeToast("This is a piece of toast", duration: 3.0, position: .bottom, style: style)
57 // or perhaps you want to use this style for all toasts going forward?
58 // just set the shared style and there's no need to provide the style again
59 ToastManager.shared.style = style
60 self.view.makeToast("This is a piece of toast") // now uses the shared style
62 // toggle "tap to dismiss" functionality
63 ToastManager.shared.tapToDismissEnabled = true
65 // toggle queueing behavior
66 ToastManager.shared.queueEnabled = true
69 See the demo project for more examples.
75 [CocoaPods](http://cocoapods.org)
78 To integrate Toast-Swift into your Xcode project using CocoaPods, specify it in your `Podfile`:
81 pod 'Toast-Swift', '~> 3.0.1'
84 and in your code add `import Toast_Swift`.
86 [Carthage](https://github.com/Carthage/Carthage)
89 To integrate Toast-Swift into your Xcode project using Carthage, specify it in your `Cartfile`:
92 github "scalessec/Toast-Swift" ~> 3.0.1
95 Run `carthage update` to build the framework and drag the built `ToastSwiftFramework.framework` into your Xcode project.
97 and in your code add `import ToastSwiftFramework`.
102 1. Add `Toast.swift` to your project.
103 2. Grab yourself a cold 🍺.
107 * Version `3.0.0` and later requires Swift 4 and Xcode 9.
108 * Version `2.0.0` requires Swift 3 and Xcode 8.
109 * Version `1.4.0` requires Swift 2.2 and Xcode 7.3.
110 * Version `1.0.0` can be used with Swift 2.1 and earlier versions of Xcode.
114 Copyright (c) 2015-2017 Charles Scalesse.
116 Permission is hereby granted, free of charge, to any person obtaining a
117 copy of this software and associated documentation files (the
118 "Software"), to deal in the Software without restriction, including
119 without limitation the rights to use, copy, modify, merge, publish,
120 distribute, sublicense, and/or sell copies of the Software, and to
121 permit persons to whom the Software is furnished to do so, subject to
122 the following conditions:
124 The above copyright notice and this permission notice shall be included
125 in all copies or substantial portions of the Software.
127 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
128 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
129 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
130 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
131 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
132 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
133 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.