Skip to content

Instantly share code, notes, and snippets.

@fpg1503
Created July 28, 2016 18:34
Show Gist options
  • Save fpg1503/882f7514b4140eaff28fb9e4bd9c9a10 to your computer and use it in GitHub Desktop.
Save fpg1503/882f7514b4140eaff28fb9e4bd9c9a10 to your computer and use it in GitHub Desktop.
Pixel Perfect Constraint
import UIKit
/// A subclass of NSLayoutConstraint where the constant is in pixels and not points
final class PixelPerfectConstraint: NSLayoutConstraint {
@IBInspectable var constantInPixels: Int = 0 {
didSet {
constant = CGFloat(constantInPixels) / UIScreen.mainScreen().scale
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment