A Simple ActionSheet writen in Swift
CocoaPods
pod install 'SimpleActionSheet'
Carthage
SimpleActionSheet is also available through Carthage. Append this line to Cartfile and follow this instruction.
github "wgywgy/SimpleActionSheet"
- iOS 8.0+
STEP1: Init a ActionSheet and ActionSheetItem.
lazy var actionSheet: ActionSheet = {
return ActionSheet()
}()
lazy var actionSheetItem: [ActionSheetItemModel] = {
let logoutActionItem = ActionSheetItem(title: "Logout") { [unowned self] (actionSheet) in
self.logout()
}
let cancelActionItem = CancelActionSheetItem { (actionSheet) in
print("cancel")
actionSheet.dismiss()
}
return [logoutActionItem, cancelActionItem]
}()
STEP 2: Define ActionSheet in extension.
extension ActionSheet {
class var logoutStyle: [ActionSheetOption] {
return [
.sepLineHeight(1),
.sepLineColor(.lightGray),
.sepLineLeftMargin(20)
]
}
}
STEP 3: Show Action as below.
actionSheet.items = actionSheetItem
actionSheet.showInWindow(options: ActionSheet.logoutStyle)
More method can look at ActionSheet.swift.
SimpleActionSheet is released under the MIT license. See LICENSE for details.