Skip to content

Instantly share code, notes, and snippets.

@troyharris
Created June 29, 2013 15:35
Show Gist options
  • Save troyharris/5891570 to your computer and use it in GitHub Desktop.
Save troyharris/5891570 to your computer and use it in GitHub Desktop.
Get the center of the view regardless of orientation: x is always horizontal and y is always vertical based on the current rotation
+(CGPoint)getViewRealCenter:(UIView *)view {
CGPoint realCenter;
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
realCenter = UIInterfaceOrientationIsLandscape(orientation) ? CGPointMake(view.center.y, view.center.x) : view.center;
return realCenter;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment