要运行示例项目,克隆仓库,然后首先从 Example 目录运行 pod install
MFAlertView 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中
pod "MFAlertView"
MFAlertView 包含 3 个主要组件
Alert View - Alert View 是原生 iOS UIAlertView 的替代品。它提供了一些定制选项,但主要目的是提供一个快速的方式,以显示任意数量的动作的对话框。Alert View 提供了一种非常快速且简单的方式来显示一行文本文本、图片或自定义视图的按钮。
要创建一个基本的带有文本按钮的 Alert View
[MFAlertView showWithTitle:@"Alert"
body:@"These are some basic text buttons."
buttonTitles:@[@"Cool", @"Wow", @"Meh"]
dismiss:nil];
或带有图片
[MFAlertView showWithTitle:@"Alert"
body:@"These are some image buttons."
buttonImages:@[[UIImage imageNamed:@"new"], [UIImage imageNamed:@"edit"], [UIImage imageNamed:@"delete"]]
dismiss:nil];
或带有自定义视图,以指示成功/失败
[MFAlertView showWithTitle:@"Alert"
body:@"These are custom views."
buttonViews:@[view1, view2, view3]
dismiss:nil];
到表示进度
[MFAlertView showSuccessAlertWithTitle:@"Success" body:@"Whatever it was. It worked." dismiss:nil];
[MFAlertView showFailureAlertWithTitle:@"Uh Oh" body:@"There was a problem." dismiss:nil];
Activity Indicator - Activity Indicator 可以按照命令显示和消失,也可以用作进度指示器。
添加一个 Activity Indicator 的方法是
[MFAlertView showActivityIndicator];
然后移除它
[MFAlertView hideActivityIndicator];
Activity Indicator 还可以显示进度
[MFAlertView showActivityIndicatorWithProgress:0 title:@"Downloading" dimBackground:YES completion:^{
[MFAlertView setProgress:0.1];
[MFAlertView setProgress:0.2];
.
.
[MFAlertView setProgress:1.0];
[MFAlertView hideActivityIndicator];
}];
Status Updates - 状态更新是会在主视图顶部短暂显示的标签,用于指示某些状态的变化。
要显示一个状态更新
[MFAlertView showStatusUpdateWithTitle:@"Status Update" autoDismiss:YES completion:^{
. . .
}];
要在一个自定义位置展示状态更新
[MFAlertView showStatusUpdateWithTitle:@"Dark Status"
location:CGPointMake(200, 200)
dark:YES
autoDismiss:YES
completion:nil];
mohssenfathi, [email protected]
MFAlertView 在 MIT 许可下可用。有关更多信息,请参阅 LICENSE 文件。