Программно реализовано
установить предел
let calendar = Calendar.current
let currentDate = Date()
var components = DateComponents()
components.calendar = calendar
components.year = -100
let minDate = calendar.date(byAdding: components, to: currentDate)!
components.year = -7
let maxDate = calendar.date(byAdding: components, to: currentDate)!
datePicker.minimumDate = minDate
datePicker.maximumDate = maxDate
вызов метода при изменении значения
@objc fileprivate func datePickerChanged() {
print(datePicker.date)
}
Цель
datePicker.addTarget(self, action: #selector(datePickerChanged), for: .valueChanged)