All Projects → MinMao-Hub → MMActionSheet

MinMao-Hub / MMActionSheet

Licence: MIT license
An actionSheet view implement with pure swift

Programming Languages

swift
15916 projects
ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to MMActionSheet

Table
CLI tables in Swift
Stars: ✭ 53 (+112%)
Mutual labels:  swift-package-manager, spm, swift5
TVToday
iOS TV Shows app with TMDb Api. RxSwift, MVVM, Clean Architecture. Tuist + Swift Package Manager
Stars: ✭ 27 (+8%)
Mutual labels:  swift-package-manager, spm, swift5
SwiftGradients
Useful extensions for UIViews and CALayer classes to add beautiful color gradients.
Stars: ✭ 15 (-40%)
Mutual labels:  swift-package-manager, spm, swift5
Hippolyte
HTTP Stubbing in Swift
Stars: ✭ 109 (+336%)
Mutual labels:  swift-package-manager, spm, swift5
PagedLists
Paginated UITableView and UICollectionViews for iOS.
Stars: ✭ 69 (+176%)
Mutual labels:  swift-package-manager, spm, swift5
Match3Kit
Library for simple Match3 games.
Stars: ✭ 38 (+52%)
Mutual labels:  swift-package-manager, spm, swift5
Aksidemenu
Beautiful iOS side menu library with parallax effect. Written in Swift
Stars: ✭ 216 (+764%)
Mutual labels:  swift-package-manager, spm
extensions-kit
📦 Collection of Swift+Apple Frameworks extensions for speeding up software development [iOS & iPadOS].
Stars: ✭ 71 (+184%)
Mutual labels:  swift-package-manager, spm
Swift-FFDB
a Object/Relational Mapping (ORM) support to iOS and MacOS .Since SwiftFFDB is build on top of FMDB.
Stars: ✭ 22 (-12%)
Mutual labels:  swift-package-manager, swift5
CSV
A simple CSV file parser and serializer
Stars: ✭ 31 (+24%)
Mutual labels:  swift-package-manager, spm
Expandable Collection View Kit
🗂 Expandable, hierarchical, flexible, declarative UICollectionView with diffable data sources & SwiftUI-like tree items builder [Swift 5.1, iOS & iPadOS 13].
Stars: ✭ 69 (+176%)
Mutual labels:  swift-package-manager, spm
SupportEmail
Pre-populates emails with support information in iOS/iPadOS apps
Stars: ✭ 20 (-20%)
Mutual labels:  swift-package-manager, spm
SwiftDown
📦 A themable markdown editor component for your SwiftUI apps.
Stars: ✭ 203 (+712%)
Mutual labels:  swift-package-manager, spm
Carekit
CareKit is an open source software framework for creating apps that help people better understand and manage their health.
Stars: ✭ 2,142 (+8468%)
Mutual labels:  swift-package-manager, swift5
Flexcolorpicker
Modern color picker library written in Swift 5 that can be easily extended and customized. It aims to provide great UX and performance with stable, quality code.
Stars: ✭ 164 (+556%)
Mutual labels:  swift-package-manager, spm
swift-watch
Watches over your Swift project's source
Stars: ✭ 43 (+72%)
Mutual labels:  swift-package-manager, spm
Bettersegmentedcontrol
An easy to use, customizable replacement for UISegmentedControl & UISwitch.
Stars: ✭ 1,782 (+7028%)
Mutual labels:  swift-package-manager, swift5
SwiftZip
Swift wrapper for libzip — library for reading, creating, and modifying zip archives.
Stars: ✭ 44 (+76%)
Mutual labels:  swift-package-manager, spm
awesome-ios
A collaborative list of awesome for iOS developers. Include quick preview.
Stars: ✭ 1,329 (+5216%)
Mutual labels:  spm, swift5
Sketchkit
A lightweight auto-layout DSL library for iOS & tvOS.
Stars: ✭ 40 (+60%)
Mutual labels:  swift-package-manager, spm

Building Language CocoaPods compatible Platform License: MIT

Introduction

MMActionSheet 是一个简单的弹出选择框,使用纯swift编写,类似于微信的actionsheet

MMActionSheet is an simple pop-up selection box(ActionSheet) written in pure Swift. Similar to the wechat actionsheet

Rquirements

  • iOS 8.0+
  • swift 4.0+

Installation

Swift Package Manager

To install with Swift Package Manager, add this package to your project’s 'Swift Packages' section. Or add the following line to your Package.swift:

 .package(url: "https://github.com/MinMao-Hub/MMActionSheet.git", from: "2.0.0")

Install with Cocoapods

  • To install MMActionSheet using CocoaPods, integrate it in your existing Podfile, or create a new Podfile:

     platform :ios, '8.0'
     use_frameworks!
     
     target 'MyApp' do
       pod 'MMActionSheet', '~> 2.0'
     end
    
  • Execute command:

    • pod repo update master
    • pod install
  • Import MMActionSheet in you code

    • import MMActionSheet

Manual import

Just clone and add components dir to your project.

Example

desc preview
Has Cancel buttons and Title
【有标题和取消按钮】
Has a Cancel button but no Title
【无标题有取消按钮】
No Cancel button and no Title
【无标题无取消按钮】
Has a Title but no Cancel button
【有标题无取消按钮】
Customize text color
【自定义文本颜色】
Customize title background color, etc
【自定义背景色、选中背景色等】
Multi data scrolling
【多数据滚动】
Set top CornerRadius
【设置顶部圆角】

Usage

let buttons = [
	MMButtonItem(title: "拍照", titleColor: .default, buttonType: .default(index: 0)),
	MMButtonItem(title: "相册", titleColor: .default, buttonType: .default(index: 1)),
]

let titleItem = MMTitleItem(title: "请选择照片", titleColor: .red)
let cancelButton = MMButtonItem(title: "取消", titleColor: .default, buttonType: .cancel)

let mmActionSheet = MMActionSheet(title: titleItem, buttons: buttons, duration: nil, cancelButton: cancelButton)
mmActionSheet.selectionClosure = { item in
    if let currentItem = item, let type = currentItem.buttonType {
        switch type {
        case let .default(index):
            print("== default index \(index) ==")
        case .cancel:
            print("cancel")
        }
    }
}
mmActionSheet.present()

PS:注释

  • create actionsheet && init 【创建并初始化】

MMActionSheet(title: titleItem, buttons: buttons, duration: nil, cancelButton: cancelButton)

  • argument【参数描述】

    • title 头部标题,类型为 MMTitleItem

    • buttons 事件按钮数组,类型为Array<MMButtonItem>,里面包含每一个按钮的具体属性:

       public var title: String?
       public var titleColor: MMButtonTitleColor? = .default
       public var titleFont: UIFont? = .systemFont(ofSize: 16.0)
       public var buttonType: MMButtonType?
       public var backgroudImageColorNormal: MMButtonTitleColor? = .custom(MMTools.DefaultColor.normalColor)
       public var backgroudImageColorHighlight: MMButtonTitleColor? = .custom(MMTools.DefaultColor.highlightColor)
      
      • title 按钮标题
      • titleColor 按钮颜色
      • titleFont 按钮字体
      • type 按钮类型(展示不同的标题颜色)【枚举类型 - default,blue,danger, custom
      • backgroudImageColorNormal 正常背景色
      • backgroudImageColorHighlight 选中背景色
    • duration 动画时长

    • cancelBtn 取消按钮属性,属性跟上述buttons内部button属性一致;若设置为nil则不显示该按钮

  • callback【回调】

mmActionSheet.selectionClosure = { item in
	if let currentItem = item, let type = currentItem.buttonType {
        switch type {
        case let .default(index):
            print("== default index \(index) ==")
        case .cancel:
            print("cancel")
        }
    }
}

item 该handler即为buttons里面的MMButtonItem,对应的回调过来

  • present【弹出actionsheet】

mmActionSheet.present()

Contribution

You are welcome to fork and submit pull requests.

License

MMActionSheet is open-sourced software licensed under the MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].