iOS swift 经验笔记

// 由UIDatePicker 获得年龄
// MARK: Get age

 let now = Date()
    let gregorian = Calendar(identifier: Calendar.Identifier.gregorian)
    let components = (gregorian as NSCalendar?)?.components(NSCalendar.Unit.year, from: birthdayPicker.date, to: now, options: [])
    let age: Int? = components?.year

你可能感兴趣的:(iOS swift 经验笔记)