Automatic select a date in datepicker in swift lan

2019-05-23 08:57发布

I have a date "Thursday, 18 Sep 2014" in this format. when i click a "change date" button. how we can automatic select a this date in datepicker in swift language.

1条回答
混吃等死
2楼-- · 2019-05-23 09:25
var dateString = "Thursday, 18 Sep 2014"
var df = NSDateFormatter()
df.dateFormat = "eeee, dd MM yyyy"
var date = df.dateFromString(dateString)
if let unwrappedDate = date {
    datePicker.setDate(unwrappedDate, animated: false)
}
查看更多
登录 后发表回答