2024-11-26
必须包裹在DispatchQueue.main.async
里面。
必须在开头添加self.
DispatchQueue.main.async{
self.cityLabel.text = weather.cityName
self.temperatureLabel.text = weather.temperaturestring
self.conditionImageView.image = UIImage(named: weather.conditionName)
}
asyncAfter(.now()+2) 指隔2秒触发。
DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
myText = "This is the new text!"
}