- iOS 8.0+
- Xcode 7.0+
BHToast is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "BHToast"
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()
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()
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()
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 these properties:
- The time that
BHToast
stays inUIView
. 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 margin. Default: 8.0
margin: 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 view position. Default: BHToastPosition.bottom
position: BHToastPosition
- The image position (if set). Default: BHToastImagePosition.Left
imagePosition: BHToastImagePosition
All those properties have a default value. Change them to apply the customizations to all new BHToast
instances.
Bruno Hecktheuer, bbheck@gmail.com
BHToast is available under the MIT license. See the LICENSE file for more info.