AnotherNewCoder
AnotherNewCoder

Reputation: 93

How to add an existing date to a UIDatePicker

I want to add the abbility, to edit an existing action with an attribute date which comes from a datePicker. Than I have to assign the date to a datePicker.

Question

How can I assign this date to a datePicker?

Upvotes: 0

Views: 30

Answers (1)

ukim
ukim

Reputation: 2465

Just set the date property

let picker = UIDatePicker()
let date = Date() // current date
picker.date = date

If you want animation you can do:

let picker = UIDatePicker()
let date = Date()
picker.setDate(date, animated: true)

A good way to solve such problem is to read documentation of UIDatePicker

Upvotes: 2

Related Questions