MaterialActionSheetController 1.0

MaterialActionSheetController 1.0

测试已测试
语言语言 SwiftSwift
许可 MIT
发布最新发布2016年8月
SPM支持 SPM

Thanh-Nhon Nguyen 维护。




  • Thanh-Nhon Nguyen

MaterialActionSheetController

轻量且完全可定制。创建和展示方式与 UIAlertController 一致。

屏幕截图

  • 演示
默认浅色主题 深色主题 自定义头部

特性

  • [x] 使用闭包配置操作
  • [x] 带有可选图标和辅助视图的操作
  • [x] 处理辅助视图上的触摸操作
  • [x] 在部分中单独列出长操作列表
  • [x] 2 个内置主题:浅色和深色
  • [x] 可自定义头部

待办事项

  • Swift 3 兼容
  • 在 iPad 上以弹出窗口展示

需求

  • iOS 8.0+
  • Xcode 7.3

安装

手动安装

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 文件。