Skip to content

Instantly share code, notes, and snippets.

@dimitribouniol
Last active December 14, 2015 12:18
Show Gist options
  • Save dimitribouniol/5085495 to your computer and use it in GitHub Desktop.
Save dimitribouniol/5085495 to your computer and use it in GitHub Desktop.
Some simple functions to help with graphics and positioning on retina devices.
static __inline__ CGFloat MDRound(CGFloat value)
{
static CGFloat scale = 0;
if (scale <= 0) {
scale = [[UIScreen mainScreen] scale];
}
return roundf(value*scale)/scale;
}
static __inline__ CGFloat MDPixel()
{
static CGFloat scale = 0;
if (scale <= 0) {
scale = [[UIScreen mainScreen] scale];
}
return 1./scale;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment