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

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

TONYLABS 28 Feb, 2020
  • 0
  • 0
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"))
}

订阅并保持联系

输入您的电子邮箱即可在第一时间获得 TONYLABS 资讯