Here's an example of how can you do it using Transforms:- The code works with all the elements that inherits from UIView
UIView.animate(withDuration: 0.5) {
self.yourButton.imageView?.transform = CGAffineTransform(rotationAngle: CGFloat.pi)
}
To set it back to original position:-
UIView.animate(withDuration: 0.5) {
self.yourButton.imageView?.transform = .identity)
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.