FMAlertController
描述
FMAlertController 是 UIAlertController 的另一个选择,有人说偷说剩下的!但我创建此警报的原因是,在某个时候,UIAlertController 仍然存在更改整个应用的色调颜色的错误。
警报完全优化,可以处理标题和消息的过长文本,并为每个按钮提供了不同类型的动画。
预览演示
安装
CocoaPods
CocoaPods 是 Cocoa 项目的依赖管理器。要使用 CocoaPods 安装 FMAlertController
-
请确保已安装 CocoaPods。安装
-
将您的 Podfile 更新为以下内容
use_frameworks!
pod 'FMAlertController'
- 运行
pod install
。
- 在你的代码中,像这样导入 FMAlertController:
import FMAlertController
使用
2.1) 使用单个按钮
2) 显示警告// send title, message and button title with completion block also with your prefered animation
FMAlertController.show("Hello", message: "AlertWithCancel", cancelButtonTitle: "Cancel", completionBlock: { () -> (Void) in
print("Cancel Pressed")
}, animationStyle: .default)
// send title, message and button title with completion block also with your prefered animation
FMAlertController.show("Hello", message: "AlertWithCancelAndOK", firstButtonTitle: "OK", firstActionCompletion: { () -> (Void) in
print("OK Pressed")
}, cancelButtonTitle: "Cancel", cancelCompletionBlock: { () -> (Void) in
print("Cancel Pressed")
}, animationStyle: .default)
// send title, message and button title with completion block also with your prefered animation
FMAlertController.show("Hello", message: "AlertWithThreeButtons", firstButtonTitle: "Share", firstButtonCompletionBlock: { () -> (Void) in
print("Share Pressed")
}, secondButtonTitle: "Rate", secondButtonCompletionBlock: { () -> (Void) in
print("Rate Pressed")
}, cancelButtonTitle: "Cancel", cancelCompletionBlock: { () -> (Void) in
print("Cancel Pressed")
}, animationStyle: .default)
public enum animationType{
case `default`
case shake
case slideDown
case slideUp
case slideRight
case slideLeft
case fade
}
要求
- Swift 5.0+
- IOS 8.0+
许可协议
麻省理工学院许可证 (MIT)
版权所有 © AaoIi 2016
以下内容是授予任何获得此软件及相关文档副本(以下简称“软件”)的人士的无偿许可,允许在不限制的方式下处理该软件,包括但不限于使用、复制、修改、合并、出版、分发、许可及/或转售软件副本,并允许提供软件的人士允许其他人这样做,但须遵守以下条件
上述版权声明和本许可声明应包含在软件所有副本或主要内容中。
软件按“现状”提供,不提供任何形式的质量保证,包括但不限于适销性保证、针对特定目的的适用性保证及非侵权保证。在任何情况下,包括但不限于合同行为、侵权或其他行为,作者或版权所有者不对任何索赔、损失或其他责任承担责任,无论源于、与或因软件或其使用或其他方式而产生。