TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | BSD |
ReleasedLast Release | Dec 2014 |
Maintained by Unclaimed.
BDToastAlert provides you an easy way to display non-obstructive messages to user without having to worry about its behavior and conflicts with other views.
The first major version release. Version 1.0.0.
Since this is a major release, there is incompatibility with previous betas. :( Sorry, Early adopters. But this version API is simpler, and more importantly, now it looks great! See below.
Out of the box, all you need to do is first get the singleton like this:
BDToastAlert *toast = [BDToastAlert shared];
In order to display a message, call:
UIViewController *ctrl = <a view contorller…>
[toast showToastWithText:@"Hello!" onViewController:ctrl];
That's it! You should see your text on the controller's view.
BDToastAlert works out of the box. However, you can customize it quite a bit if you like with these properties
verticalAlignment
defines where the toast should appear on the specified view.customToastViewClassName
defines the class name of your own custom toast view. Two ways:
Though you can start from scratch with a custom UIView for a custom toast view, I recommend subclassing the BDDefaultToastView
class. This is the default view that BDToastAlert
uses out of the box.
An example for customizing toast view by subclassing BDDefaultToastView
.
To change the toast font, override the -init
method, like this
- (id)init
{
self = [super init];
if (self) {
self.textLabel.font = <your font>;
}
return self;
}
If you guess that the textLabel
property is the UILabel
on the BDDefaultToastView
class, then you are correct. You can configure the label any way you like. For the background gradient, the following methods: configure how it looks
startGradientColor
endGradientColor
shadowColor
backgroundRadius
You can subclass a UIView
for your custom toast with the following requirements:
BDToastViewProtocol
-init
method. This is becauseBDToastAlert
, set the class name to its customToastViewClassName
property. The BDToastAlert
singleton creates an instance of your custom toast view using -init
method only.QuartzCore.framework
With CocoaPods, add to your dependency list.
dependency 'BDToastAlert'
Without CocoaPods, just include h/.m files in BDToastAlert folder to your project source code
BDToastAlert is licensed under BSD. More info in LICENSE file.