-
Date Formatter (원하는 모습으로 날짜 출력)UIKit 2020. 8. 17. 22:11
let formatter: DateFormatter = { let f = DateFormatter() f.dateStyle = .long f.timeStyle = .short f.locale = Locale(identifier: "Ko_kr") return f }()
클로저를 사용하여, formatter 변수를 만듦과 동시에 설정까지 해줍니다.
그리고나서 formatter.string(from: target.insertDate)를 추가하여 from의 변수를 위에서 설정한 모양대로 나오도록 해줍니다.
아래는 결과이미지입니다.
'UIKit' 카테고리의 다른 글
Hex to Color (0) 2020.08.18 Notification Example (0) 2020.08.18 Alert Controller (0) 2020.08.18 Notification Center (0) 2020.07.04 View Controller의 생명주기 (0) 2020.07.04