Reputation: 3134
I can get my buttons to hide, but not unhide.
I hide the answerOneCover
button on tap with:
@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
})
}
And I try to unhide the answerOneCover
button when a different button, answerOneButtonText
button is tapped:
@IBAction func answerOneButtonTextTapped(_ sender: Any) {
answerOneCover.isHidden = false
}
But I can't get answerOneCover
to unhide. Is there any way to do this that I'm missing?
Upvotes: 1
Views: 104
Reputation: 500
You have to set the buttons Alpha back to 1. change your code to look like this:
@IBAction func answerOneButtonTextTapped(_ sender: Any) {
answerOneCover.alpha = 1
answerOneCover.isHidden = false
}
OR you can put it in your animations completion like so:
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
})
}
Upvotes: 3