Latest 0.1.0
Homepage https://github.com/comodinx/ToastSimple
License MIT
Platforms ios 8.0
Authors

Version Platform License

├Źndice

Features

  • Simple
  • UIView extension
  • Personalizable

Screen Shots


Demo Example

Prerequisites

  • iOS 8+
  • Xcode 7+
  • Swift 3.0

Installation

ToastSimple is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "ToastSimple"

How to Use

Your use documentation.

Example

view.showToast("This is a example toast notification")
// or
view.showToast("This is a example toast notification", title: "Information!")
// or
view.showToast(
    "This is a example toast notification",
    title: "Information!",
    image: UIImage(named: "yourimage")
)
// or
view.showToast(
    "This is a example toast notification",
    duration: 2.5, // Seconds
    title: "Information!",
    image: UIImage(named: "yourimage")
)
// or
view.showToast(
    "This is a example toast notification",
    duration: 2.5, // Seconds
    position: .Center, // .Top (default), .Center or .Bottom
    title: "Information!",
    image: UIImage(named: "yourimage")
)
// or
view.showToast(
    toast: UIView(), // Your custom view
    duration: 2.5, // Seconds
    position: .Center // .Top (default), .Center or .Bottom
)
// or
view.showToast(
    toast: UIView(), // Your custom view
    duration: 2.5, // Seconds
    position: .Center, // .Top (default), .Center or .Bottom
) {
    // your code to execute on toast completion hide
}

API

Configuration

Toast configuration.

// animation
ToastSimpleConfig.Duration: TimeInterval = 2.0
ToastSimpleConfig.AnimationDuration: TimeInterval = 0.2

// image size
ToastSimpleConfig.ImageViewWidth: CGFloat = 80.0
ToastSimpleConfig.ImageViewHeight: CGFloat = 80.0

// label setting
ToastSimpleConfig.MaxWidth: CGFloat = 0.8 // 80% of parent view width
ToastSimpleConfig.MaxHeight: CGFloat = 0.8
ToastSimpleConfig.MaxTitleLines = 0
ToastSimpleConfig.MaxMessageLines = 0
ToastSimpleConfig.TitleFontType: UIFont = UIFont.systemFont(ofSize: 16)
ToastSimpleConfig.TitleFontColor: UIColor = .black
ToastSimpleConfig.TitleAlign: NSTextAlignment = .center
ToastSimpleConfig.MessageFontType: UIFont = UIFont.systemFont(ofSize: 13)
ToastSimpleConfig.MessageFontColor: UIColor = .black
ToastSimpleConfig.MessageAlign: NSTextAlignment = .center

// shadow appearance
ToastSimpleConfig.ShadowOpacity: CGFloat = 0.8
ToastSimpleConfig.ShadowRadius: CGFloat = 6.0
ToastSimpleConfig.ShadowOffset: CGSize = CGSize(
    width: CGFloat(4.0),
    height: CGFloat(4.0)
)

ToastSimpleConfig.BackgroundColor: UIColor = .gray
ToastSimpleConfig.Position: ToastSimplePosition = .Top
ToastSimpleConfig.Opacity: CGFloat = 0.9
ToastSimpleConfig.CornerRadius: CGFloat = 10.0
ToastSimpleConfig.HorizontalMargin : CGFloat = 10.0
ToastSimpleConfig.VerticalMargin: CGFloat = 22.0

ToastSimpleConfig.HidesOnTap = true
ToastSimpleConfig.DisplayShadow = true

Personalize

import ToastSimple

// ...
class AppDelegate: UIResponder, UIApplicationDelegate {

    // ...

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.

        // Configure toast
        ToastSimpleConfig.BackgroundColor = .gray
        ToastSimpleConfig.TitleFontColor = .black
        ToastSimpleConfig.TitleFontType = UIFont.systemFont(ofSize: 17)
        ToastSimpleConfig.MessageFontColor = .black
        ToastSimpleConfig.MessageFontType = UIFont.systemFont(ofSize: 15)
        ToastSimpleConfig.Duration = 5
        ToastSimpleConfig.AnimationDuration = 0.75

        return true
    }

    // ...

}

License

ToastSimple is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "ToastSimple",
    "version": "0.1.0",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "summary": "ToastSimple written in Swift",
    "homepage": "https://github.com/comodinx/ToastSimple",
    "screenshots": "https://raw.githubusercontent.com/comodinx/ToastSimple/master/Screenshots/DemoExample.gif",
    "authors": {
        "Nicolas Molina": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/comodinx/ToastSimple.git",
        "tag": "0.1.0"
    },
    "source_files": "Sources/*.swift",
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This