TDNotificationPanel is a drop in class that displays a notification which can contain a title, subtitle, icon, progress bar or activity indicator.
Until version 1.0 expect changes to the API.
TDNotificationPanel has been tested on iOS 6+ and requires ARC. It depends on the following Apple frameworks:
CocoaPods is the recommended way to add TDNotificationPanel to your project.
pod 'TDNotificationPanel', '~> 0.5.1'
.#import "TDNotificationPanel.h"
.Add the following files located in TDNotificationPanel
directory to your project. Then include TDNotificationPanel wherever you need it with #import "TDNotificationPanel.h"
.
There are 3 different notification types these are:
There are 3 different notification modes these are:
Please note when using TDNotificationModeActivityIndicator and TDNotificationModeProgressBar the notification type TDNotificationTypeMessage will be used.
To display a notification panel use the following method:
[TDNotificationPanel showNotificationInView:self.view
title:@"Notification Title"
subtitle:@"Notification Subtitle"
type:TDNotificationTypeError
mode:TDNotificationModeText
dismissible:YES
hideAfterDelay:3];
If you need to run a long task with a progress bar use the following method:
TDNotificationPanel *panel = [[TDNotificationPanel alloc] initWithView:self.view
title:@"Posting Message"
subtitle:nil
type:TDNotificationTypeMessage
mode:TDNotificationModeProgressBar
dismissible:NO];
[[self view] addSubview:panel];
[panel show];
[self longRunningTaskWithProgress:^(float)progress {
[panel setProgress:progress];
} completion:^{
[panel hideAfterDelay:3];
}];
A completion handler can be set and will be called when the notification is dismissed.
[TDNotificationPanel showNotificationInView:self.view
title:@"Notification Title"
subtitle:@"Notification Subtitle"
type:TDNotificationTypeError
mode:TDNotificationModeText
dismissible:YES
hideAfterDelay:3
completionHandler:^{
NSLog(@"Completion Handler");
];
All notifications are added to a queue and displayed sequentially.
[TDNotificationPanel showNotificationInView:self.view
title:@"Notification 1"
subtitle:@"Notification 1 Subtitle"
type:TDNotificationTypeError
mode:TDNotificationModeText
dismissible:YES
hideAfterDelay:3];
[TDNotificationPanel showNotificationInView:self.view
title:@"Notification 2 Title"
subtitle:@"Notification 2 Subtitle"
type:TDNotificationTypeSuccess
mode:TDNotificationModeText
dismissible:YES
hideAfterDelay:3];
TDNotificationPanel is distributed under the MIT License.
Changelog can be viewed here.