MLVAlertKit 是一个可定制的 alert 和 action sheet UI 框架,类似于 UIAlertController,但我们对出现和消失动画进行了改动以提高用户体验,同时您也可以自定义文本属性。
MLVAlertKit 版本 | 最低 iOS 目标 | 描述 |
---|---|---|
1.0.0 | iOS 8 | |
1.1.0 | iOS 7 | 添加 UITextField 支持 |
MLVAlertKit 可以使用 CocoaPods、Cathage 添加到项目中,也可以使用项目包含的源文件。
或者您可以将源文件直接添加到项目中。
MLVAlertKit.h
、MLVAlertController.h
、MLVAlertController.m
、MLVAlertAnimator.h
、MLVAlertAnimator.m
拖放到您的项目中(当在项目外部提取代码存档时请确保选择“复制项目”)。#import "MLVAlertKit.h"
将 MLVAlertKit 包含在您需要的位置。您可以从任何 UIViewController(如 UIAlertController)中呈现 alert。
MLVAlertController *alert = [MLVAlertController alertControllerWithTitle:@"Remind !!" message:@"Support is on Github" preferredStyle:MLVAlertControllerStyleAlert];
MLVAlertAction *cancel = [MLVAlertAction actionWithTitle:@"Cancel" style:MLVAlertActionStyleCancel handler:^(MLVAlertAction * _Nonnull action) {
}];
[alert addAction:cancel];
[self presentViewController:alert animated:YES completion:NULL];
使用引用添加 UITextFields:
- (void)addTextFieldWithConfigurationHandler:(void (^ __nullable)(UITextField *textField))configurationHandler;
如果您需要配置属性,可以使用 MLVAlertController 引用这样操作:
+ (instancetype)alertControllerWithAttributedTitle:(nullable NSAttributedString *)title message:(nullable NSAttributedString *)message preferredStyle:(MLVAlertControllerStyle)preferredStyle;
+ (instancetype)actionWithAttributedTitle:(NSAttributedString *)title style:(MLVAlertActionStyle)style handler:(void (^ __nullable)(MLVAlertAction *action))handler;
更多示例,请下载 MLVAlertKit 并尝试 iPhone 示例应用
MLVAlertKit 基于 MIT 许可证发布。有关详情,请参阅 LICENSE。