DTActionSheet 1.0.2

DTActionSheet 1.0.2

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Mar 2018
SPMSupports SPM

Maintained by Dan Jiang, Dan Jiang.



DTActionSheet

Swift Platform CocoaPods Carthage compatible

Introduction

Simple customizable action sheet.

Demo

Installation

Requirement

iOS 8.4+

CocoaPods

To install DTActionSheet add a dependency to your Podfile:

pod "DTActionSheet"

Carthage

To install DTActionSheet add a dependency to your Cartfile:

github "danjiang/DTActionSheet"
carthage update --platform ios

Usage

Import

import DTActionSheet

Inheritance

Subclass following 3 classes with subtle differences:

  • DTActionSheet - Full customizable
  • DTDismissibleActionSheet - With dismiss button on the left
  • DTSavableActionSheet - With dismiss button on the left and save button on the right

You can review source code of DTDatePickerSheet to know how to write your own action sheet.

Reusable Components

  • DTDatePickerSheet - UIDatePicker in action sheet.
  • More to come...

Use

class ViewController: UIViewController {
  
  private let formatter = DateFormatter()
  
  override func viewDidLoad() {
    super.viewDidLoad()
    
    formatter.dateStyle = .short
  }

  @IBAction func changeDate(_ sender: UIButton) {
    let sheet = DTDatePickerSheet(style: .dark)
    sheet.setTitle("Choose Date")
    sheet.configDatePicker(mode: .date, date: Date()) { [unowned self] date in
      let title = self.formatter.string(from: date)
      sender.setTitle(title, for: .normal)
    }
    sheet.show()
  }
  
}