Last active
September 19, 2020 21:02
-
-
Save Inferis/26ded6e1e8e625b3cd67 to your computer and use it in GitHub Desktop.
Revisions
-
Tom Adriaenssen renamed this gist
Apr 25, 2015 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
Tom Adriaenssen created this gist
Apr 25, 2015 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,51 @@ - (UIInterfaceOrientation)orientationByTransforming:(CGAffineTransform)transform fromOrientation:(UIInterfaceOrientation)c { CGFloat angle = atan2f(transform.b, transform.a); NSInteger multiplier = (NSInteger)roundf(angle / M_PI_2); UIInterfaceOrientation orientation = self.interfaceOrientation; if (multiplier < 0) { // clockwise rotation while (multiplier++ < 0) { switch (orientation) { case UIInterfaceOrientationPortrait: orientation = UIInterfaceOrientationLandscapeLeft; break; case UIInterfaceOrientationLandscapeLeft: orientation = UIInterfaceOrientationPortraitUpsideDown; break; case UIInterfaceOrientationPortraitUpsideDown: orientation = UIInterfaceOrientationLandscapeRight; break; case UIInterfaceOrientationLandscapeRight: orientation = UIInterfaceOrientationPortrait; break; default: break; } } } else if (multiplier > 0) { // counter-clockwise rotation while (multiplier-- > 0) { switch (orientation) { case UIInterfaceOrientationPortrait: orientation = UIInterfaceOrientationLandscapeRight; break; case UIInterfaceOrientationLandscapeRight: orientation = UIInterfaceOrientationPortraitUpsideDown; break; case UIInterfaceOrientationPortraitUpsideDown: orientation = UIInterfaceOrientationLandscapeLeft; break; case UIInterfaceOrientationLandscapeLeft: orientation = UIInterfaceOrientationPortrait; break; default: break; } } } return (UIInterfaceOrientation)orientation; }