rotate 180 degree for an UIImageView, and rotate back with same route rotate 180 degree for an UIImageView, and rotate back with same route xcode xcode

rotate 180 degree for an UIImageView, and rotate back with same route


instead of -M_PI, use -3.14159. Kind of a trick, but below code saved my day.

self.DashButton.imageView.transform = CGAffineTransformMakeRotation(M_PI);self.DashButton.imageView.transform = CGAffineTransformMakeRotation(M_PI - 3.14159);


self.DashButton.imageView.transform = CGAffineTransformMakeRotation(M_PI);self.DashButton.imageView.transform = CGAffineTransformMakeRotation(0);


what you need is a negative angle to rotate it in the opposite direction

CGAffineTransformMakeRotation( 180 * CGFloat(M_PI/180))

CGAffineTransformMakeRotation(-1 * CGFloat(M_PI/180))

take a look at this answer for an explanation About CGAffineTransformMakeRotation rotation direction?