XMAlertSheetController 是一个 Swift 库,它提供自定义操作表。
它将为用户提供丰富的体验,而不必费力编写酷炫的动画代码。
Hokusai 与 Swift4 兼容。
安装
将类文件夹放入您的 Xcode 项目中。
您还可以使用 Cocoapods 或 Carthage。
Cocoapods
使用将 pod 'XMAlertSheetController'
添加到您的 Podfile
并运行 pod install
。同时,请将 use_frameworks!
添加到 Podfile
中。
use_frameworks!
pod 'XMAlertSheetController'
Carthage
使用将 github "iMazy/XMAlertSheetController"
添加到您的 Cartfile
并运行 carthage update
。如果您不熟悉 Carthage,请查看他们的入门部分。
github "iMazy/XMAlertSheetController"
XMAlertSheetController 使用方法
导入 XMAlertSheetController import XMAlertSheetController
,然后在非 viewDidLoad 的任何函数中使用以下代码。
let alertSheet = XMAlertSheetController(title: "MainTitle", message: "A short description...")
// Add a button with a closure
alertSheet.addAction(XMAlertAction(title: "No Thanks", style: .default, action: {
// do some thing with defalt action
}))
alertSheet.addAction(XMAlertAction(title: "Allow", style: .destructive, action: {
// do some thing with destructive action
}))
// Add a callback for cancel button (Optional)
alertSheet.addAction(XMAlertAction(title: "Cancel", style: .cancel))
// Show Hokusai
self.present(alertSheet, animated: true, completion: nil)
添加标题和消息
// Init with title and message
let alertSheet = XMAlertSheetController(title: Information, message: "This can be a long multi-lined message.")
添加一个带有闭包的按钮
alertSheet.addAction(XMAlertAction(title: "Button Title", style: .default, action: {
// Do anything you want
}))
作者
iMazy
http://imazy.cn
反馈
您可以通过以下邮箱反馈给我 [email protected]
许可
XMAlertSheetController是在MIT许可证下发布的。
查看_LICENSE获取详细信息。