Scenario: I have a '>' button:
that is supposed to animate +90 degrees upon initial tap:
However after returning to the 0 degree '>' position via tapping on the UITableViewCell again which returns to its original height; then tapping AGAIN I get a further rotation to the '<' position:
How do I freeze the max rotation to only the 90 degrees (pointing down); so that I have the single +/- 90 deg rotation toggle?
Here's my code:
func rotate2ImageView() {
UIView.animate(withDuration: 0.3) {
self.rightArrowImage.transform = self.rightArrowImage.transform.rotated(by: .pi / 2)
}
}
Here's a failed remedy (where I tried to remove all animations):
func rotateImageView(){
UIView.animate(withDuration: 0.3, animations: {() -> Void in
self.rightArrowImage.transform = self.rightArrowImage.transform.rotated(by: .pi / 2)
}, completion: {(_ finished: Bool) -> Void in
if finished {
self.rightArrowImage.layer.removeAllAnimations()
}
})
}