Skip to content

Commit e387279

Browse files
Update readme
1 parent 71053ef commit e387279

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

README.mdown

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
1-
# DatePickerDialog 3.0- iOS - Swift
1+
# DatePickerDialog 4.0 - iOS - Swift
22

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

55
[![](https://raw.githubusercontent.com/squimer/DatePickerDialog-iOS-Swift/master/images/screen1.png)](https://github.com/squimer/DatePickerDialog-iOS-Swift/tree/master/images)
66

77
## Requirements
88

9-
DatePickerDialog works on iOS 7, 8 and 9, 10, 11 and 12. It depends on the following Apple frameworks, which should already be included with most Xcode templates:
9+
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:
1010

1111
* Foundation
1212
* UIKit
1313

1414
#### Swift Versions
15-
- Swift 5.0 (Current)
15+
- Swift 5.3 (Current)
16+
- Swift 4.2 (```3.0``` tag)
1617
- Swift 4.2 (```2.1``` tag)
1718
- Swift 4.2 (```2.0``` tag)
1819
- Swift 2.3 (```swift_2.3``` branch)
1920

2021
## Installation
2122
#### CocoaPods
23+
2224
You can use [CocoaPods](http://cocoapods.org/) to install `DatePickerDialog` by adding it to your `Podfile`:
2325

2426
```ruby
@@ -47,19 +49,19 @@ github "squimer/DatePickerDialog-iOS-Swift"
4749
## Example
4850

4951
```swift
50-
func datePickerTapped() {
51-
DatePickerDialog().show(title: "DatePicker", doneButtonTitle: "Done", cancelButtonTitle: "Cancel", datePickerMode: .date) {
52-
(date) -> Void in
53-
if let dt = date {
54-
let formatter = DateFormatter()
55-
formatter.dateFormat = "MM/dd/yyyy"
56-
self.textField.text = formatter.string(from: dt)
57-
}
52+
func datePickerTapped() {
53+
DatePickerDialog().show(title: "DatePicker", doneButtonTitle: "Done", cancelButtonTitle: "Cancel", datePickerMode: .date) { date in
54+
if let dt = date {
55+
let formatter = DateFormatter()
56+
formatter.dateFormat = "MM/dd/yyyy"
57+
self.textField.text = formatter.string(from: dt)
5858
}
5959
}
60+
}
6061
```
6162

6263
## Dialog parameters
64+
6365
- showCancelButton: Bool - default true
6466
- locale: Locale? - default nil
6567

@@ -73,7 +75,6 @@ Example with custom locale:
7375
DatePickerDialog(locale: Locale(identifier: "es_PY")).show(title: "DatePicker", doneButtonTitle: "Done", datePickerMode: .date)
7476
```
7577

76-
7778
## Show parameters
7879

7980
- title: String **(Required)**

Sources/DatePickerDialog.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ open class DatePickerDialog: UIView {
3333
private var buttonColor: UIColor!
3434
private var font: UIFont!
3535

36-
private lazy var container = UIView()
36+
private var container: UIView?
3737
private lazy var gradient = CAGradientLayer(layer: self.layer)
3838

3939
// MARK: - Dialog initialization
@@ -179,6 +179,8 @@ open class DatePickerDialog: UIView {
179179
self.frame = CGRect(x: 0, y: 0, width: screenSize.width, height: screenSize.height)
180180

181181
// This is the dialog's container; we attach the custom content and the buttons to this one
182+
let container = UIView()
183+
self.container = container
182184
container.frame = CGRect(
183185
x: (screenSize.width - dialogSize.width) / 2,
184186
y: (screenSize.height - dialogSize.height) / 2,
@@ -310,7 +312,7 @@ open class DatePickerDialog: UIView {
310312

311313
open override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
312314
super.traitCollectionDidChange(previousTraitCollection)
313-
container.layer.borderColor = Colors.separator.cgColor
315+
container?.layer.borderColor = Colors.separator.cgColor
314316
gradient.colors = Colors.gradientBackground
315317
}
316318
}

0 commit comments

Comments
 (0)