Skip to content

Instantly share code, notes, and snippets.

@kastiglione
Forked from mpospese/CGRectIntegralScaled.m
Created March 1, 2013 21:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kastiglione/5067973 to your computer and use it in GitHub Desktop.
Save kastiglione/5067973 to your computer and use it in GitHub Desktop.
CGRect CGRectIntegralScaledEx(CGRect rect, CGFloat scale)
{
return CGRectMake(floorf(rect.origin.x * scale) / scale, floorf(rect.origin.y * scale) / scale, ceilf(rect.size.width * scale) / scale, ceilf(rect.size.height * scale) / scale);
}
CGRect CGRectIntegralScaled(CGRect rect)
{
return CGRectIntegralScaledEx(rect, [[UIScreen mainScreen] scale]);
}
CGRect CGRectIntegralMake(CGFloat x, CGFloat y, CGFloat width, CGFloat height)
{
return CGRectIntegralScaledEx(CGRectMake(x, y, width, height), [[UIScreen mainScreen] scale]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment