dan085 / DTActionSheet

Simple customizable action sheet

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DTActionSheet

Swift Platform CocoaPods Carthage compatible

Introduction

Simple customizable action sheet.

Demo

Installation

Requirement

iOS 8.4+

To install DTActionSheet add a dependency to your Podfile:

pod "DTActionSheet"

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()
  }
  
}

About

Simple customizable action sheet

License:MIT License


Languages

Language:Swift 91.4%Language:Ruby 5.0%Language:Objective-C 3.6%