我有两个标签:label1 和 label2。在标签 1 中想要日期,在标签 2 中我想要月份和日期。
例子:
星期四
6 月 30 日
let today = Date()
let weekday = Calendar.current.component(.weekday, from: today)
let month = Calendar.current.component(.month, from: today)
let date = Calendar.current.component(.day, from: today)
label1.text = Calendar.current.weekdaySymbols[weekday-1]
label2.text = "\(Calendar.current.shortMonthSymbols[month-1]) \(date)"
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句