TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | Custom |
ReleasedLast Release | Sep 2016 |
SPMSupports SPM | ✗ |
Maintained by Suyeol Jeon.
Android-like toast with very simple interface.
JLToast.makeText("Some text").show()
JLToast.h
to use JLToast in Objective-C.For iOS 8+ projects with CocoaPods:
pod 'JLToast', '~> 1.4'
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.4.2', :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)
Removing toast with reference:
let toast = JLToast.makeText("Hello")
toast.show()
toast.cancel() // remove toast immediately
Removing current toast:
if let currentToast = JLToastCenter.defaultCenter.currentToast {
currentToast.cancel()
}
Removing all toasts:
JLToastCenter.defaultCenter.cancelAllToasts()
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.