Skip to content

KakoDev/DatePickerDialog-iOS-Swift

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DatePickerDialog 1.1 - 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. It depends on the following Apple frameworks, which should already be included with most Xcode templates:

  • Foundation
  • UIKit
  • QuartzCore

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/DatePickerDialog.framework to an iOS project.

github "squimer/DatePickerDialog-iOS-Swift"

Manually

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

Example

class ViewController: UIViewController {

	@IBOutlet weak var textField: UITextField!

	override func viewDidLoad() {
		super.viewDidLoad()
	}

	/* IBActions */
	@IBAction func datePickerTapped(sender: AnyObject) {
		DatePickerDialog().show(title: "DatePicker", doneButtonTitle: "Done", cancelButtonTitle: "Cancel", datePickerMode: .Date) {
			(date) -> Void in
			self.textField.text = "\(date)"
		}
	}

}

Show parameters

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

Todo

  • Handle device orientation changes.
  • Improve performance.

Special thanks to

License

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

About

Date picker dialog for iOS

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 97.7%
  • Ruby 2.3%