scalessec/Toast-Swift

Name: Toast-Swift

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

Created: 2015-11-01 19:33:32.0

Updated: 2018-01-22 01:32:25.0

Pushed: 2018-01-16 15:28:17.0

Homepage: null

Size: 604

Language: Swift

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

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
asic usage
.view.makeToast("This is a piece of toast")

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

oast presented with multiple options and with a completion closure
.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")
}


isplay toast with an activity spinner
.view.makeToastActivity(.center)

isplay any view as toast
.view.showToast(myView)

mmediately hides all toast views in self.view
.view.hideAllToasts()
But wait, there's more!
reate a new style
style = ToastStyle()

his is just one of many style options
e.messageColor = .blue

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

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

oggle "tap to dismiss" functionality
tManager.shared.isTapToDismissEnabled = true

oggle queueing behavior
tManager.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:

'Toast-Swift', '~> 3.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:

ub "scalessec/Toast-Swift" ~> 3.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.

Manually
  1. Add Toast.swift to your project.
  2. Grab yourself a cold ?.
Compatibility
MIT License
Copyright (c) 2015-2017 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.

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.