DTActionSheet
简介
简单的可定制操作表。
安装
要求
iOS 8.4+
CocoaPods
要安装 DTActionSheet,请在您的 Podfile 中添加一个依赖项
pod "DTActionSheet"
Carthage
要安装 DTActionSheet,请在您的 Cartfile 中添加一个依赖项
github "danjiang/DTActionSheet"
carthage update --platform ios
使用方法
导入
import DTActionSheet
继承
以下三个子类具有微小差异
- DTActionSheet - 完全可定制
- DTDismissibleActionSheet - 包含左侧的关闭按钮
- DTSavableActionSheet - 包含左侧的关闭按钮和右侧的保存按钮
您可以查看 DTDatePickerSheet
的源代码,了解如何编写您自己的操作表。
可重用组件
- DTDatePickerSheet - 在操作表中使用 UIDatePicker。
- 更多内容即将推出...
使用
class ViewController: UIViewController {
private let formatter = DateFormatter()
override func viewDidLoad() {
super.viewDidLoad()
formatter.dateStyle = .short
}
@IBAction func changeDate(_ sender: UIButton) {
let sheet = DTDatePickerSheet(style: .dark)
sheet.setTitle("Choose Date")
sheet.configDatePicker(mode: .date, date: Date()) { [unowned self] date in
let title = self.formatter.string(from: date)
sender.setTitle(title, for: .normal)
}
sheet.show()
}
}