Class
DSDatePicker
@IBDesignable public final class DSDatePicker: UIView
An Enterprise-styled date & time picker. This should be used when a user needs to select a date, time, or both a date and time.
For storyboards, add a UIView and change the class name to DSDatePicker.
Initialize and set properties as needed.
let picker = DSDatePicker(dateType: .datetime)
picker.datePickerDelegate = self
picker.labelText = "Appointment Schedule"
picker.date = Date()
Use a DSDatePickerDelegate to detect when its tapped so you can present the picker view. You can supply standard UIDatePicker options using DSDatePickerControlOptions.
func datePickerTapped(_ picker: DSDatePicker) {
let options = DSDatePickerControlOptions()
options.minimumDate = Date()
picker.showDateSelection(on: navigationController, options: options)
}
Relationships
Conforms To
UIView
Initializers
init(frame:)
public override init(frame: CGRect)
init(dateType:)
public init(dateType: DSDatePickerDateType)
Properties
datePickerDelegate
@IBOutlet public weak var datePickerDelegate: DSDatePickerDelegate?
The delegate which receives updates on the DSDatePicker's state.
dateType
public var dateType: DSDatePickerDateType = .date
The style of date & time selection desired.
dateTypeString
@IBInspectable public var dateTypeString: String
The dateType property representable by a String.
This property is only recommended for use in the Attributes inspector of a storyboard since enums are not @IBInspectable. Possible values are date, time and datetime. In code, use the dateType property instead.
isEnabled
@IBInspectable public var isEnabled: Bool = true
Returns true if the component is enabled and allows changing the value.
Methods
awakeFromNib()
public override func awakeFromNib()
prepareForInterfaceBuilder()
public override func prepareForInterfaceBuilder()
showDateSelection(on:options:)
func showDateSelection(on viewController: UIViewController?, options: DSDatePickerControlOptions? = nil)
Displays the date & time selection modal by presenting on a UIViewController.
Parameters
Name | Type | Description |
---|---|---|
on | UIViewController? |
The UIViewController to push display the modal on |