Skip to content

Instantly share code, notes, and snippets.

@michaeleisel
Last active December 12, 2018 18:45
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 michaeleisel/4f5099c5745a746e34cad6fe3767b501 to your computer and use it in GitHub Desktop.
Save michaeleisel/4f5099c5745a746e34cad6fe3767b501 to your computer and use it in GitHub Desktop.
extension CGRect {
var isAligned: Bool {
get {
return origin.x.isAligned && origin.y.isAligned && size.width.isAligned && size.height.isAligned
}
}
}
extension CGFloat {
var isAligned: Bool {
get {
let (_, errorPart) = modf(self * UIScreen.main.scale)
return errorPart < 0.001
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment