As I understand it, you are trying to rotate the view in the animation block. animateWithDuration will always perform the animation in the shortest animateWithDuration way. Thus, M_PI and -M_PI give the same destination position. The reason you get the expected direction of the animation when manually tuned is because your manual value is really less than the M_PI, so the shortest way is to turn it counterclockwise.
To get the expected behavior, you will need to combine at least two animations, dividing the rotation angle. for instance
//first animation block myView.transform = CGAffineTransformMakeRotation(CGFloat(-M_PI/2))CGAffineTransformMakeRotation; //second animation block myView.transform = CGAffineTransformMakeRotation(CGFloat(-M_PI/2))CGAffineTransformMakeRotation;
Swift 3.0
myView.transform = CGAffineTransform(rotationAngle: CGFloat(-M_PI/2))
Or, much more reliably, use CAKeyframeAnimation
source share