Tuesday, 10 September 2013

About CGAffineTransformMakeRotation rotation direction?

About CGAffineTransformMakeRotation rotation direction?

I'm trying to use CGAffineTransformMakeRotation, and I refer Apple
document which says
The angle, in radians, by which this matrix rotates the coordinate system
axes. In iOS, a positive value specifies counterclockwise rotation and a
negative value specifies clockwise rotation. In OS X, a positive value
specifies clockwise rotation and a negative value specifies
counterclockwise rotation.
So, I pass parameter 90 degree, it should counterclockwise rotation.
self.myView is gray background color view, and red square view is just for
see rotation direction
#define DEGREES_TO_RADIANS(x) (x * M_PI/180.0)
CGAffineTransform rotation = CGAffineTransformMakeRotation(
DEGREES_TO_RADIANS(90) );
[self.myView setTransform:rotation];


But why it clockwise rotation?
I'm trying use in simulator and device both have the same result,
clockwise rotation
And then tring to use animation:
#define DEGREES_TO_RADIANS(x) (x * M_PI/180.0)
CGAffineTransform rotation = CGAffineTransformMakeRotation(
DEGREES_TO_RADIANS(90) );
[UIView animateWithDuration:0.5
animations:^{
self.myView.transform = rotation;
}
completion:^(BOOL finished) {
NSLog(@"%@",
NSStringFromCGAffineTransform(self.myView.transform));
}];
It has the same result, clockwise rotation.
Can somebody explain why, Thanks for the reply.

No comments:

Post a Comment