Skip to content

wgywgy/SimpleActionSheet

Repository files navigation

SimpleActionSheet

A Simple ActionSheet writen in Swift

Build Status codebeat badge Carthage Compatible

Screenshots

Screenshots1

Install

CocoaPods

pod install 'SimpleActionSheet'

Carthage

SimpleActionSheet is also available through Carthage. Append this line to Cartfile and follow this instruction.

github "wgywgy/SimpleActionSheet"

Requirements

  • iOS 8.0+

Use

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.

License

SimpleActionSheet is released under the MIT license. See LICENSE for details.

About

A Simple ActionSheet writen in Swift

Resources

License

Stars

Watchers

Forks

Packages

No packages published