JFMinimalNotifications 0.0.9

JFMinimalNotifications 0.0.9

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布日期上次发布日期2017年1月

Jeremy Fox 维护。




JFMinimalNotification

这是一个专为 iOSUIView 设计的用于显示美丽通知的类,具有高度可配置性,适用于 iPhone 和 iPad。JFMinimalNotification 仅在 ARC 中可用,并针对 iOS 7.0 及以上版本。

在寻找 Android 版本吗?Garrett Franks 为您创建了一个,非常棒,您可以查看:https://github.com/gfranks/GFMinimalNotifications

显示效果

Example Example

您可以看到此控件的一个简短视频:https://www.youtube.com/watch?v=jDYC-NYKl9A

屏幕截图

Examples

如何使用

基本示例

- (void)viewDidLoad
{
    [super viewDidLoad];

    /**
     * Create the notification
     */
    self.minimalNotification = [JFMinimalNotification notificationWithStyle:JFMinimalNotificationStyleDefault
                                                                      title:@"This is my awesome title"
                                                                   subTitle:@"This is my awesome sub-title"];

    /**
     * Set the desired font for the title and sub-title labels
     * Default is System Normal
     */
    UIFont* titleFont = [UIFont fontWithName:@"STHeitiK-Light" size:22];
    [self.minimalNotification setTitleFont:titleFont];
    UIFont* subTitleFont = [UIFont fontWithName:@"STHeitiK-Light" size:16];
    [self.minimalNotification setSubTitleFont:subTitleFont];

    /**
     * Set any necessary edge padding as needed
     */
    self.minimalNotification.edgePadding = UIEdgeInsetsMake(0, 0, 10, 0);

    /**
     * Add the notification to a view
     */
    [self.view addSubview:self.minimalNotification];
}

/**
 * Showing the notification from a button handler
 */
- (IBAction)show:(id)sender {
    [self.minimalNotification show];
}

/**
 * Hiding the notification from a button handler
 */
- (IBAction)dismiss:(id)sender {
    [self.minimalNotification dismiss];
}

构造函数 / 选项

/**
 * Note: passing a dismissalDelay of 0 means the notification will NOT be automatically dismissed, you will need to 
 * dismiss the notification yourself by calling -dismiss on the notification object. If you pass a dismissalDelay 
 * value greater than 0, this will be the length of time the notification will remain visisble before being 
 * automatically dismissed.
 */

// With dismissalDelay
self.minimalNotification = [JFMinimalNotification notificationWithStyle:JFMinimalNotificationStyleError title:@"This is my awesome title" subTitle:@"This is my awesome sub-title" dismissalDelay:3.0];

// Without dismissalDelay and with touchHandler
self.minimalNotification = [JFMinimalNotification notificationWithStyle:JFMinimalNotificationStyleError title:@"This is my awesome title" subTitle:@"This is my awesome sub-title" dismissalDelay:0.0 touchHandler:^{
    [self.minimalNotification dismiss];
}];
// Available Styles
typedef NS_ENUM(NSInteger, JFMinimalNotificationStyle) {
    JFMinimalNotificationStyleDefault,
    JFMinimalNotificationStyleError,
    JFMinimalNotificationStyleSuccess,
    JFMinimalNotificationStyleInfo,
    JFMinimalNotificationStyleWarning
};

请在此存储库中查看示例项目,了解如何使用此通知。

委托方法

- (void)minimalNotificationWillShowNotification:(JFMinimalNotification*)notification;
- (void)minimalNotificationDidShowNotification:(JFMinimalNotification*)notification;
- (void)minimalNotificationWillDisimissNotification:(JFMinimalNotification*)notification;
- (void)minimalNotificationDidDismissNotification:(JFMinimalNotification*)notification;

安装

将源代码直接包含到您的项目中

  • 只需将 "JFMinimalNotification" 文件夹中的源文件复制到您的项目中。
  • 在您应用程序的项目 app 目标设置中,找到 "构建阶段" 部分,打开 "链接二进制与库" 块,然后单击 "+" 按钮并选择 "CoreGraphics.framework"。

许可证

版权所有 (c) 2012 Jeremy Fox (jeremyfox.me)。保留所有权利。

在此授予任何人获得本软件及其相关文档文件(简称“软件”)副本(以下简称“软件”)的使用权,不受限制,包括但不限于使用、复制、修改、合并、发布、分发、再许可和/或出售软件副本的权利,并允许取得软件的人拥有icanso所提供的软件进行此类处理,但须遵守以下条件

上述版权声明和本许可声明应包含在所有软件副本或主要部分中。

软件按“原样”提供,不提供任何形式的保证,无论是明示的还是推定的,包括但不限于适销性、针对特定目的的适用性和非侵权性。在任何情况下,作者或版权所有者不应对任何索赔、损害或其他责任负责,无论是在合同行为、侵权或其他行为中,这些损害或赔偿是由于软件或软件的使用或其他方式而产生的。