根据当前时间显示 “上午好” “下午好“ ”晚上好“

根据当前时间显示 “上午好” “下午好“ ”晚上好“

发布日期: 28th Feb, 2020
分享:

let hour = Calendar.current.component(.hour, from: Date())
switch hour {
	case 6..<12 : print(NSLocalizedString("Morning", comment: "Morning"))
	case 12 : print(NSLocalizedString("Noon", comment: "Noon"))
	case 13..<17 : print(NSLocalizedString("Afternoon", comment: "Afternoon"))
	case 17..<22 : print(NSLocalizedString("Evening", comment: "Evening"))
	default: print(NSLocalizedString("Night", comment: "Night"))
}
分享:

0 Comments

  • Dave Austin 1 day ago

    Reply

发表评论