반응형
SMALL
swift 현재 시간 출력
1. 변수 선언
@IBOutlet weak var label: UILabel!
var timer:Timer!
2. 시간 출력
// 1초 마다 timerProc 메소드 실행
timer = Timer.scheduledTimer(timeInterval: 1, target:self, selector:#selector(timerProc),userInfo:nil, repeats: true)
@objc func timerProc(timer:Timer){
let date = Date()
let formatter = DateFormatter();
formatter.dateFormat = "yyyy-MM-dd ccc hh:mm:ss"
let msg = formatter.string(from: date)
label.text = msg
}
반응형
LIST
'iOS - Swift' 카테고리의 다른 글
[스위프트/Swift] duplicate symbols for architecture arm64 (0) | 2019.12.30 |
---|---|
[스위프트/Swift] /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby: bad interpreter: No such file or directory (0) | 2019.10.29 |
[스위프트/Swift] UILabel 부분 속성 변경 (0) | 2019.10.23 |
[스위프트/Swift] firebase remote config 적용 (0) | 2019.10.23 |
[스위프트/Swift] 커스텀 폰트 적용 오류 (0) | 2019.10.23 |