有没有办法在按下按钮时将时间记录为字符串? 我不知道从哪里开始?
最佳答案
只需从该按钮创建 IBAction
,如下所示:
@IBAction func buttonPressed(_ sender: UIButton) {
let currentDateTime = Date()
let formatter = DateFormatter()
formatter.timeStyle = .short
formatter.dateStyle = .none
print(formatter.string(from: currentDateTime))
}
关于swift - 来自按钮的时间戳?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44742290/