UIAlertController_Blocks.swift
安装
CocoaPods
UIAlertController_Blocks.swift 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中:
pod 'UIAlertController_Blocks.swift'
Swift 包管理器
将 https://github.com/iBinh/UIAlertController_Blocks.swift.git
添加到包管理器
使用
显示操作表
UIAlertController.showActionSheet(title: "Title", message: "Message", cancelButtonTitle: "Cancel", destructiveButtonTitle: "Delete", otherButtonTitles: ["First Button", "Second Button"], popoverPresentationControllerBlock: { (popover) in
popover?.sourceView = self.someButton
popover?.sourceRect = self.someButton.bounds
}) { (controller, action, index) in
if index == controller.firstOtherButtonIndex {
// do some stuff
} else if index == controller.firstOtherButtonIndex + 1 {
// do some stuff
} else if index == controller.destructiveButtonIndex {
// do some stuff
}
// do some stuff
}
显示警告
UIAlertController.showAlert(title: "Title", message: "Message", cancelButtonTitle: "Cancel", destructiveButtonTitle: "Delete", otherButtonTitles: ["First Button", "Second Button"], popoverPresentationControllerBlock: { (popover) in
popover?.sourceView = self.someButton
popover?.sourceRect = self.someButton.bounds
}) { (controller, action, index) in
if index == controller.firstOtherButtonIndex {
// do some stuff
} else if index == controller.firstOtherButtonIndex + 1 {
// do some stuff
} else if index == controller.destructiveButtonIndex {
// do some stuff
}
// do some stuff
}
作者
灵感来源于 ryanmaxwell/UIAlertController-Blocks
ntbinh2121, [email protected]
许可协议
UIAlertController_Blocks.swift 依据 MIT 许可协议提供。详见 LICENSE 文件获取更多信息。