15
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[Swift]DatePickerに日付の範囲を設定する

Posted at

datepickerを生成

@IBOutlet weak var datePicker: UIDatePicker!

datepickerをoutlet接続します。

範囲を指定する

let minDateString = "2014-12-01"

var dateFormatter = NSDateFormatter()
dateFormatter.dateFormat = "YYYY-MM-DD"

var minDate = dateFormatter.dateFromString(minDateString)

datePicker.minimumDate = minDate
datePicker.maximumDate = NSDate()

「2014年12月1日」から「今日」までを範囲指定する場合は上のコードのようになります。

15
13
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
15
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?