BHToast 0.3.1

BHToast 0.3.1

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Jan 2016
SPMSupports SPM

Maintained by Bruno Hecktheuer.



BHToast 0.3.1

  • By
  • Bruno Hecktheuer

BHToast

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.