我可以隐藏我的按钮,但不能取消隐藏。
我隐藏answerOneCover
按钮,点按:
@IBAction func answerOneCoverTapped(_ sender: Any) {
animateButtonCoverOut(button: answerOneCover)
}
func animateButtonCoverOut(button: UIButton) {
UIView.animate(withDuration: 1.0, delay: 0.1, options:
UIViewAnimationOptions.curveEaseOut, animations: {
button.alpha = 0
}, completion: { finished in
button.isHidden = true
})
}
当我点击其他按钮answerOneCover
按钮时,我尝试取消隐藏answerOneButtonText
按钮:
@IBAction func answerOneButtonTextTapped(_ sender: Any) {
answerOneCover.isHidden = false
}
但我无法取消answerOneCover
取消隐藏。我有什么方法可以做到这一点吗?
答案 0 :(得分:3)
您必须将按钮 Alpha 设置为 1 。将代码更改为如下所示:
@IBAction func answerOneButtonTextTapped(_ sender: Any) {
answerOneCover.alpha = 1
answerOneCover.isHidden = false
}
OR 您可以将其置于动画完成中,如下所示:
func animateButtonCoverOut(button: UIButton) {
UIView.animate(withDuration: 1.0, delay: 0.1, options:
UIViewAnimationOptions.curveEaseOut, animations: {
button.alpha = 0
}, completion: { finished in
button.isHidden = true
button.alpha = 1
})
}