HMAMessageViewManager 0.1.6

HMAMessageViewManager 0.1.6

测试已测试
语言编程语言 Obj-CObjective C
许可 MIT
发布最新发布2018年3月

Jurgis Kirsakmens 维护。



  • Jurgis Kirsakmens

HMAMessageViewManager

CI Status Version License Platform

Dead simple notification message banners (appearing from bottom) for iOS.

example mov

  • No dependencies
  • Rotation support (uses autolayout)
  • Error, Warning, Success and Default types
  • Customize fonts via UIAppearance
  • No legacy code ;)

Message banner hides automatically after seconds you can define via appearance proxy (default is 3 seconds) or by user tap.

示例用法

#import "HMAMessageViewManager.h"
...
[[HMAMessageViewManager sharedManager] showMessageInController:self title:@"Oops!" subtitle:@"Did not expected this" type:HMAMessageViewTypeWarning];

为了方便,您还可以添加简单的 UIViewController 分类类,例如

#import "UIViewController+HMAMessages.h"
#import "HMAMessageViewManager.h"

@implementation UIViewController (HMAMessages)

- (void) my_showWarningMessage:(NSString *)pTitle {
    [[HMAMessageViewManager sharedManager] showMessageInController:self title:NSLocalizedString(@"Ooops!", @"Warning title for invalid data") subtitle:pTitle type:HMAMessageViewTypeWarning];
}

@end

然后只需使用

[myController my_showWarningMessage:@"Wrong email address"];

自定义

为了在您的应用代理(或任何其他地方)自定义消息标题/副标题的字体/字体大小和消息自动隐藏时间,请执行以下操作

#import "HMAMessageView.h"
...
[[HMAMessageView appearance] setTitleFont:[UIFont boldSystemFontOfSize:12]];
[[HMAMessageView appearance] setSubtitleFont:[UIFont boldSystemFontOfSize:7]];
[[HMAMessageView appearance] setHideMessagesAfterSeconds:@4];

示例

要运行示例项目,请先克隆仓库,然后从示例目录运行 pod install

需求

Xcode9,iOS11 SDK,支持iOS 10.0及以上版本

安装

HMAMessageViewManager通过CocoaPods提供。要安装它,只需在Podfile中添加以下行

pod "HMAMessageViewManager"

作者

Jurgis Kirsakmens,https://twitter.com/xjki

许可证

HMAMessageViewManager可在MIT许可证下使用。有关更多信息,请参阅LICENSE文件。