Skip to content

Instantly share code, notes, and snippets.

@623637646
Created June 18, 2021 10:47
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 623637646/76ed2881c73f5b79db217875082a3fbc to your computer and use it in GitHub Desktop.
Save 623637646/76ed2881c73f5b79db217875082a3fbc to your computer and use it in GitHub Desktop.
Round Pixel By Scale for iOS
CGFloat YNSelfSizingRoundPixelValue(CGFloat value)
{
static CGFloat scale;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^(){
scale = [UIScreen mainScreen].scale;
});
return roundf(value * scale) / scale;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment