测试已测试 | ✗ |
语言语言 | SwiftSwift |
许可 | MIT |
发布最新发布 | 2016年8月 |
SPM支持 SPM | ✗ |
由 Thanh-Nhon Nguyen 维护。
轻量且完全可定制。创建和展示方式与 UIAlertController 一致。
默认浅色主题 | 深色主题 | 自定义头部 |
---|---|---|
![]() | ![]() | ![]() |
将 MaterialActionSheetController.swift
添加到您的项目中
// Import MaterialActionSheetController if you're using CocoaPods
import MaterialActionSheetController
// Create an action
let lightBulbAction = MaterialAction(
icon: UIImage(named: "lightbulb"),
title: "Action with UISwitch as an accessory view", handler: { [unowned self] (accessoryView) in
self.doSomething()
},
accessoryView: UISwitch(),
dismissOnAccessoryTouch: true,
accessoryHandler: { [unowned self] (accessoryView) in
if let lightBulbSwitch = accessoryView as? UISwitch {
if accessoryView.on {
print("Light is ON!")
} else {
print("Light is OFF!")
}
}
self.doSomeOtherThing()
})
// Then create and present your MaterialActionSheetController
// parameter sections is a variadic which take a flexible list of section
let materialActionSheetController = MaterialActionSheetController(
title: "A nice title",
message: "A friendly message",
actionSections: [aCoolAction, anotherCoolAction], [cancelAction])
// Customize theme
materialActionSheetController.theme = MaterialActionSheetTheme.dark()
presentViewController(materialActionSheetController, animated: true, completion: nil)
参见演示中的代码以获取更详细的示例。
请随时创建 PR,贡献受到热烈欢迎和赞赏。
MaterialActionSheetController 以 MIT 许可协议提供。有关更多信息,请参阅 LICENSE 文件。