Created
July 28, 2016 18:34
-
-
Save fpg1503/882f7514b4140eaff28fb9e4bd9c9a10 to your computer and use it in GitHub Desktop.
Pixel Perfect Constraint
This file contains hidden or 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
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