Created
December 26, 2012 08:46
-
-
Save hankbao/4378943 to your computer and use it in GitHub Desktop.
Get a CGAffineTransform from a UIInterfaceOrientation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define DEGREES_TO_RADIANS(degrees) (degrees * M_PI / 180) | |
static CGAffineTransform transformForOrientation(UIInterfaceOrientation orientation) | |
{ | |
switch (orientation) { | |
case UIInterfaceOrientationLandscapeLeft: | |
return CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(90)); | |
case UIInterfaceOrientationLandscapeRight: | |
return CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(-90)); | |
case UIInterfaceOrientationPortraitUpsideDown: | |
return CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(180)); | |
case UIInterfaceOrientationPortrait: | |
default: | |
return CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(0)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment