Code Monkey home page Code Monkey logo

datepickerdialog-ios-swift's Introduction

DatePickerDialog 4.0 - iOS - Swift

DatePickerDialog is an iOS drop-in classe that displays an UIDatePicker within an UIAlertView.

Requirements

DatePickerDialog works on iOS 7, 8 and 9, 10, 11, 12, 13 and 14. It depends on the following Apple frameworks, which should already be included with most Xcode templates:

  • Foundation
  • UIKit

Swift Versions

  • Swift 5.3 (Current)
  • Swift 4.2 (3.0 tag)
  • Swift 4.2 (2.1 tag)
  • Swift 4.2 (2.0 tag)
  • Swift 2.3 (swift_2.3 branch)

Installation

CocoaPods

You can use CocoaPods to install DatePickerDialog by adding it to your Podfile:

platform :ios, '8.0'
use_frameworks!
pod 'DatePickerDialog'

To get the full benefits import DatePickerDialog wherever you import UIKit

import UIKit
import DatePickerDialog

Carthage

Create a Cartfile that lists the framework and run carthage bootstrap. Follow the instructions to add $(SRCROOT)/Carthage/Build/iOS/DatePickerDialogFramework.framework to an iOS project.

github "squimer/DatePickerDialog-iOS-Swift"

Manually

  1. Download and drop DatePickerDialog.swift in your project.
  2. Congratulations!

Example

func datePickerTapped() {
	DatePickerDialog().show(title: "DatePicker", doneButtonTitle: "Done", cancelButtonTitle: "Cancel", datePickerMode: .date) { date in
		if let dt = date {
			let formatter = DateFormatter()
			formatter.dateFormat = "MM/dd/yyyy"
			self.textField.text = formatter.string(from: dt)
		}
	}
}

Dialog parameters

  • showCancelButton: Bool - default true
  • locale: Locale? - default nil

Example without 'Cancel' button:

DatePickerDialog(showCancelButton: false).show(title: "DatePicker", doneButtonTitle: "Done", datePickerMode: .date)

Example with custom locale:

DatePickerDialog(locale: Locale(identifier: "es_PY")).show(title: "DatePicker", doneButtonTitle: "Done", datePickerMode: .date)

Show parameters

  • title: String (Required)
  • doneButtonTitle: String
  • cancelButtonTitle: String
  • defaultDate: Date
  • minimumDate: Date
  • maximumDate: Date
  • datePickerMode: UIDatePickerMode (Required)
  • callback: ((date: Date) -> Void) (Required)

Special thanks to

License

This code is distributed under the terms and conditions of the MIT license.

datepickerdialog-ios-swift's People

Contributors

aj9 avatar akshit5230 avatar benjohnde avatar diogoguimaraes avatar leonluc-dev avatar lfarah avatar madeinqc avatar misteral avatar smaugho avatar soberman avatar viniciussoares avatar voluntadpear avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.