Latest 0.3.1
Homepage https://github.com/bbheck/BHToastSwift
License MIT
Platforms ios 8.0, requires ARC
Authors

Swift
CI Status
Version
License
Platform

Requirements

  • iOS 8.0+
  • Xcode 7.0+

Installation

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

pod "BHToast"

Usage

Showing a BHToast (only message)

BHToast(view: view, message: "This is an example message.").show()

or

let toast = BHToast(view: view)

toast.message = "This is an example message."
toast.show()

Showing a BHToast (with image)

BHToast(view: view, message: "This is an example message.", imageView: `yourImageView`).show()

or

let toast = BHToast(view: view, message: "This is an example message.")

toast.imageView = `yourImageView`
toast.show()

Showing a BHToast (with options)

import BHToast

let options = BHToastOptions(
    duration: 10.0,
    borderWidth: 0.0,
    cornerRadius: 0.0
)

BHToast(view: view, message: "This is an example message.", options: options).show()

Customizing

BHToastViewTag is used to guarantee only one instance in view.
If necessary, change it before first BHToast instance.

You can create a BHToastOptions instance with this properties:

  • The time that BHToast stays in UIView. Default: 5.0

    duration: NSTimeInterval
  • The animation time (in seconds). Default: 0.4

    animationDuration: NSTimeInterval
  • Toast background color. Default: UIColor.lightGrayColor()

    backgroundColor: UIColor
  • Border color. Default: UIColor.darkGrayColor()

    borderColor: UIColor
  • Border width. Default: 1.0

    borderWidth: CGFloat
  • Corner radius. Default: 5.0

    cornerRadius: CGFloat
  • The bottom distance. Default: 8.0

    bottomOffset: CGFloat
  • The content insets. Default: UIEdgeInsetsMake(8.0, 8.0, 8.0, 8.0)

    contentInsets: UIEdgeInsets
  • The min height. Default: 30.0

    minHeight: CGFloat
  • The max height. Default: 50.0

    maxHeight: CGFloat
  • The message alignment. Default: NSTextAlignment.Center

    messageAlignment: NSTextAlignment
  • The message color. Default: UIColor.whiteColor()

    messageColor: UIColor
  • The message font. Default: UIFont.systemFontOfSize(14.0)

    messageFont: UIFont
  • The image position (if set). Default: BHToastImagePosition.Left
    imagePosition: BHToastImagePosition

All this properties have a default value. Change it to apply the customizations to all new BHToast instances.

Author

Bruno Hecktheuer, [email protected]

License

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

Latest podspec

{
    "name": "BHToast",
    "version": "0.3.1",
    "summary": "BHToast is a custom UIView written in Swift inspired by Android Toast.",
    "homepage": "https://github.com/bbheck/BHToastSwift",
    "license": "MIT",
    "authors": {
        "Bruno Hecktheuer": "[email protected]"
    },
    "source": {
        "git": "https://github.com/bbheck/BHToastSwift.git",
        "tag": "0.3.1"
    },
    "platforms": {
        "ios": "8.0"
    },
    "requires_arc": true,
    "source_files": "Pod/Classes/**/*"
}

Pin It on Pinterest

Share This