TDNotificationPanel 0.5.2

TDNotificationPanel 0.5.2

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布最新版本2015年3月

Tom Diggle 维护。




TDNotificationPanel 是一个可以插入的类,用于显示一个可以包含标题、子标题、图标、进度条或活动指示器的通知。

重要

直到版本 1.0,API 会有所变化。

要求

TDNotificationPanel 在 iOS 6+ 上进行了测试,并需要 ARC。它依赖于以下 Apple 框架

  • Foundation.framework
  • UIKit.framework
  • CoreGraphics.framework

将 TDNotificationPanel 添加到您的项目

源文件

将位于 TDNotificationPanel 目录下的以下文件添加到您的项目中。然后, wherever 您需要 TDNotificationPanel,使用 #import "TDNotificationPanel.h" 包含它。

使用方法

有 3 种不同的通知类型,分别是

  • TDNotificationTypeError
  • TDNotificationTypeMessage
  • TDNotificationTypeSuccess

有 3 种不同的通知模式,分别是

  • TDNotificationModeActivityIndicator
  • TDNotificationModeProgressBar
  • TDNotificationModeText

请注意,当使用 TDNotificationModeActivityIndicator 和 TDNotificationModeProgressBar 时,将使用 TDNotificationTypeMessage 通知类型。

要显示通知面板,请使用以下方法

[TDNotificationPanel showNotificationInView:self.view
                                      title:@"Notification Title"
                                   subtitle:@"Notification Subtitle"
                                       type:TDNotificationTypeError
                                       mode:TDNotificationModeText
                                dismissible:YES
                             hideAfterDelay:3];

如果您需要使用进度条运行长时间任务,请使用以下方法

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];
}];

完成处理程序

可以设置完成处理程序,并在通知消失时调用。

[TDNotificationPanel showNotificationInView:self.view
                                      title:@"Notification Title"
                                   subtitle:@"Notification Subtitle"
                                       type:TDNotificationTypeError
                                       mode:TDNotificationModeText
                                dismissible:YES
                             hideAfterDelay:3
                          completionHandler:^{
                                     NSLog(@"Completion Handler");
                          ];

队列

所有通知都添加到一个队列并按顺序显示。

[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 在 MIT 许可证 下发行。

更新日志

更新日志可在此处查看此处