Android-like toast with very simple interface.
JLToast.makeText("Some text").show()
- Objective-C Compatible: import
JLToast.h
to use JLToast in Objective-C. - Queueing: centralized toast center manages toast queue.
- Customizable: see Appearance section.
-
For iOS 8+ projects with CocoaPods:
pod 'JLToast', '~> 1.3'
-
For iOS 8+ projects with Carthage:
github "devxoul/JLToast" ~> 1.0
-
For iOS 7 projects: I recommend you to try CocoaSeeds, which uses source code instead of dynamic frameworks. Sample Seedfile:
github 'devxoul/JLToast', '1.3.5', :files => 'JLToast/*.{swift,h}'
JLToast is compatible with Objective-C. What you need to do is to import a auto-generated header file:
#import <JLToast/JLToast-Swift.h>
If you are looking for constants, import JLToast.h
.
#import <JLToast/JLToast-Swift.h>
#import <JLToast/JLToast.h> // if you want to use constants
JLToast.makeText("Some text", duration: JLToastDelay.LongDelay)
JLToast.makeText("Some text", delay: 1, duration: JLToastDelay.ShortDelay)
Since JLToast 1.1.0, you can set default values for appearance attributes. The code below sets default background color to red.
Note: It is not recommended to set default values while toasts are queued. It can occur unexpected results.
Swift
JLToastView.setDefaultValue(
UIColor.redColor(),
forAttributeName: JLToastViewBackgroundColorAttributeName,
userInterfaceIdiom: .Phone
)
Objective-C
[JLToastView setDefaultValue:[UIColor redColor]
forAttributeName:JLToastViewBackgroundColorAttributeName
userInterfaceIdiom:UIUserInterfaceIdiomPhone];
Attribute | Type | Description |
---|---|---|
JLToastViewBackgroundColorAttributeName |
UIColor |
Background color |
JLToastViewCornerRadiusAttributeName |
NSNumber(CGFloat) |
Corner radius |
JLToastViewTextInsetsAttributeName |
NSValue(UIEdgeInsets) |
Text inset |
JLToastViewTextColorAttributeName |
UIColor |
Text color |
JLToastViewFontAttributeName |
UIFont |
Font |
JLToastViewPortraitOffsetYAttributeName |
NSNumber(CGFloat) |
Vertical offfset from bottom in portrait mode |
JLToastViewLandscapeOffsetYAttributeName |
NSNumber(CGFloat) |
Vertical offfset from bottom in landscape mode |
JLToast is under WTFPL. You can do what the fuck you want with JLToast. See LICENSE file for more info.