当我录制按钮UILabel出现并立即再次消失。几秒后我需要它消失。这是我的第一个应用程序,我无法解决这个问题。谢谢!
func done() {
if sauserImageView.isHidden == false && cupImageView.isHidden == false && spoonImageView.isHidden == false {
winningLabel.isHidden = false
}
}
您可以使用DispatchQueue API执行延迟操作,例如
DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
self.label.isHidden = true
}
或者,如果要为隐藏设置动画,请使用UIView.animate(withDuration:animations :)或UIView.animate(withDuration:delay:options:animations:completion :)例如:
UIView.animate(withDuration: 2) {
self.label.alpha = 0
}
祝好运!