Skip to content

xiaomage1478/MGActionSheet

Repository files navigation

XMGActionSheet

CI Status Version License Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

MGActionSheet is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'XMGActionSheet'

Usage

import XMGActionSheet

import XMGActionSheet

WeChat Delete Style

MGActionSheetBuilder.show(title: "是否删除该条消息?", destructiveTitle: "确定") { _ in
    print("删除了~")
}

extension MGActionSheetBuilder {
    public static func show(title: String, destructiveTitle: String, destructiveHandle: ((MGAction) -> Void)?) {
        let titleColor = #colorLiteral(red: 0.370662272, green: 0.3664324582, blue: 0.3663428426, alpha: 1)
        let titleConfig = MGActionConfig(titleColor: titleColor, titleFont: .systemFont(ofSize: 12))
        
        let destructiveColor = #colorLiteral(red: 0.9254902005, green: 0.2352941185, blue: 0.1019607857, alpha: 1)
        let destructiveConfig = MGActionConfig(titleColor: destructiveColor, titleFont: .systemFont(ofSize: 16))
        
        let cancelColor = #colorLiteral(red: 0, green: 0, blue: 0, alpha: 1)
        let cancelConfig = MGActionConfig(titleColor: cancelColor, titleFont: .systemFont(ofSize: 16))
        
        MGActionSheetBuilder()
            .addAction(title: title, style: .default, config: titleConfig, isEnable: false)
            .addAction(title: destructiveTitle, style: .destructive, config: destructiveConfig, handler: destructiveHandle)
            .addCancleAction(config: cancelConfig)
            .build()
    }
}

Normal Style

    MGActionSheetBuilder()
        .addAction(title: "退出网页版文件传输助手?", style: .default, isEnable: false)
        .addAction(title: "退出", style: .destructive)
        .addCancleAction()
        .build()

Subtitle Style

    MGActionSheetBuilder()
        .addAction(title: "拍摄", subtitle: "照片或视频", style: .default)
        .addAction(title: "从手机相册选择", style: .default)
        .addCancleAction()
        .build()

Custom Action Height

  1. isAutoHeight = false is fixed height for action
    MGActionSheetBuilder()
        .addAction(title: "退出网页版文件传输助手?", style: .default, config: MGActionConfig(titleFont: .systemFont(ofSize: 16, weight: .medium),isAutoHeight: false, actionHeight: 80), isEnable: false)
        .addAction(title: "退出", style: .destructive)
        .addCancleAction()
        .build()
  1. isAutoHeight = true and set actionMinHeight is auto height for action
    MGActionSheetBuilder()
        .addAction(title: "退出网页版文件传输助手?", style: .default, config: MGActionConfig(titleFont: .systemFont(ofSize: 16, weight: .medium),isAutoHeight: true, actionMinHeight: 80), isEnable: false)
        .addAction(title: "退出", style: .destructive)
        .addCancleAction()
        .build()

Author

小马哥, [email protected]

License

MGActionSheet is available under the MIT license. See the LICENSE file for more info.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published