Created
June 18, 2021 10:47
-
-
Save 623637646/76ed2881c73f5b79db217875082a3fbc to your computer and use it in GitHub Desktop.
Round Pixel By Scale for iOS
This file contains 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 characters
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