EHPlainAlert 1.2.7

EHPlainAlert 1.2.7

测试已测试
语言语言 Obj-CObjective C
许可协议 MIT
发布最后发布2016年12月

Danila Gusev 维护。



  • Danila Gusev

这是一个简单的扩展,用于从设备屏幕底部显示多个全局通知。

要求

  • 需要 iOS 7.1 或更高版本
  • 需要自动引用计数(ARC)

特性

  • 支持一个屏幕上的多条消息
  • 简单的使用操作
  • 高度可定制
  • 可以从应用中的任何位置调用

使用方法

#import <EHPlainAlert/EHPlainAlert.h>

显示通知

所有消息都可以通过静态方法调用来简单地显示

[EHPlainAlert showAlertWithTitle:@"Success" message:@"Something works!" type:ViewAlertSuccess];

可以在应用中的任何位置显示消息,甚至是与 UI 无关的位置。

[[NetHelper sharedInstance] postRequestWithURLString:URL data:data withSuccess:^(id responseObject) {
        [EHPlainAlert showAlertWithTitle:@"Success" message:@"Data successfully uploaded" type:ViewAlertSuccess];
    } failure:^(NSError *error)
    {
        [EHPlainAlert showError:error];
    }];

显示错误通知

为了简化错误处理,您可以使用以下方法:

- (void)someError:(NSError *)myError
{
    [EHPlainAlert showError:error];
}

隐藏消息

通知将在 4 秒后自动隐藏。

要更改默认延迟,请使用以下静态方法:[EHPlainAlert updateHidingDelay:2.5f];

您还可以只需轻触消息即可隐藏它。

轻触动作

您可以更改轻触通知时的默认行为

EHPlainAlert * ehAlert = [[EHPlainAlert alloc] initWithTitle:@"Hmm..." message:@"Tap for information" type:ViewAlertInfo];
ehAlert.action = ^{
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://github.com/josshad/EHPlainAlert"]];
};
[ehAlert show];

定制

字体

更改一个警告的字体

EHPlainAlert * ehAlert = [[EHPlainAlert alloc] initWithTitle:@"Info" message:@"This is info message" type:ViewAlertInfo];
ehAlert.titleFont = [UIFont fontWithName:@"TrebuchetMS" size:15];
ehAlert.subTitleFont = [UIFont fontWithName:@"TrebuchetMS-Italic" size:12];
[ehAlert show];

更改警告类型字体

[EHPlainAlert updateTitleFont:[UIFont fontWithName:@"TrebuchetMS" size:18]];
[EHPlainAlert updateSubTitleFont:[UIFont fontWithName:@"TrebuchetMS" size:10]];

颜色

更改一个警告的背景颜色

EHPlainAlert * ehAlert = [[EHPlainAlert alloc] initWithTitle:@"Hmm..." message:@"Blue color alert" type:ViewAlertInfo];
ehAlert.messageColor = [UIColor blueColor];
[ehAlert show];

更改警告类型的颜色

[EHPlainAlert updateAlertColor:[UIColor colorWithWhite:0 alpha:0.5] forType:ViewAlertPanic];

外观

[EHPlainAlert updateAlertPosition:ViewAlertPositionTop];

图标

更改一个警告的图标

EHPlainAlert * ehAlert = [[EHPlainAlert alloc] initWithTitle:@"Hmm..." message:@"Blue color alert" type:ViewAlertInfo];
ehAlert.iconImage = image;
[ehAlert show];

更改警告类型的图标

[EHPlainAlert updateAlertIcon:image forType:ViewAlertInfo]; 

消息数量

[EHPlainAlert updateNumberOfAlerts:4];

显示时间

[EHPlainAlert updateHidingDelay:2.5f];

作者

Danila Gusev

[email protected]

许可证

使用受MIT许可证约束。有关详细信息,请参阅LICENSE