SKNotification 1.6

SKNotification 1.6

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

Sandor Kolotenko 维护。



  • 作者:
  • Sandor Kolotenko

为 CocoaPods


简约、易于自定义的隐形应用通知。

自定义

  • 大文本的自动调整大小
  • 支持本地化键 (NSLocalizedString)
  • 不同状态的颜色和图标(例如警告、失败)
  • 无图标的提醒
  • 支持自定义字体
  • 支持半透明提醒
  • 单屏显示多个提醒
  • 成功完成或取消的代码块
  • 单击取消

alt text 仍在开发中,请注意可能的轻微错误。如发现,请报告问题。

使用方法

有几种方式来显示通知:使用本地化键或直接字符串

以下是方法签名和用法示例

- (void)setImageWithName:(NSString*)imageName forType:(SKNotificationType)type;

- (void)show:(SKNotificationType)type withMessage:(NSString*)message in:(UIViewController*)controller;

- (void)show:(SKNotificationType)type withLocalizedKey:(NSString *)key in:(UIViewController *)controller;

- (void)show:(SKNotificationType)type withMessage:(NSString*)message in:(UIViewController*)controller withCompletion:(void (^)(void))completion;

- (void)show:(SKNotificationType)type withLocalizedKey:(NSString *)key in:(UIViewController *)controller withCompletion:(void (^)(void))completion;

- (void)show:(SKNotificationType)type withMessage:(NSString*)message in:(UIViewController*)controller withCompletion:(void (^)(void))completion andCancelation:(void (^)(void))cancelation;

- (void)show:(SKNotificationType)type withLocalizedKey:(NSString *)key in:(UIViewController *)controller withCompletion:(void (^)(void))completion andCancelation:(void (^)(void))cancelation;

[[SKNotification centre] show:SKNSuccess
                      withMessage:@"Alert, your location is too far from the actual address."
                               in:self withCompletion:^{
                                   NSLog(@"Completed 2");
                               }];

默认颜色下的样子,这些颜色可以完全自定义

alt text

alt text

alt text

通知类型

typedef NS_ENUM(NSInteger, SKNotificationType){
    SKNSuccess,
    SKNFailure,
    SKNAlert,
    SKNInfo,
    SKNCustom
};

额外的动画选项

typedef NS_ENUM(NSInteger, SKAnimationType){
    SKAnimationSmooth,
    SKAnimationQuickDrop,
    SKAnimationSlowDrop
};

额外的选项和使用方法

[[SKNotification centre] setImageWithName:@"alert" forType:SKNAlert];
[[SKNotification centre] setImageWithName:@"success" forType:SKNSuccess];
[[SKNotification centre] setImageWithName:@"failure" forType:SKNFailure];
[[SKNotification centre] setImageWithName:@"info" forType:SKNInfo];
[[SKNotification centre] setDisplayDuration:1.85f];
[[SKNotification centre] shouldDropShadow:YES];
[[SKNotification centre] setMessageFont:[UIFont fontWithName:@"HelveticaNeue-Light" size:12.0f]];

[[SKNotification centre] setTransparent:NO];
[[SKNotification centre] setAlpha:1.0f];
[[SKNotification centre] setDisplayDuration:2.5f];
[[SKNotification centre] setMessageFont:[UIFont systemFontOfSize:13.0f]];
[[SKNotification centre] setUseAutomaticTextColor:YES];
[[SKNotification centre] setElastic:YES];