Created
October 22, 2016 16:55
-
-
Save bdalziel/335723f7871500182b34fb3207401f10 to your computer and use it in GitHub Desktop.
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
// Between Title and Description | |
// 1. Get height below title baseline which is poking out below a grid line - get the value that would make this poke a whole 8 px. | |
CGFloat titleDescenderRoundedToNextGridline = 8 - fmod([ASPFontUtil getUITextElementBelowBaselineHeight:ASPUITextElementContentCardTitle traitCollection:contextTraitCollection], 8) ; | |
// 2. Get height above description baseline that is poking above a grid line - get the value that would make this poke a whole 8 px. | |
CGFloat descriptionAscenderRoundedToNextGridline = 8 - fmod([ASPFontUtil getUITextElementAboveBaselineHeight:ASPUITextElementContentCardDescription traitCollection:contextTraitCollection], 8) ; | |
// 3. Round sum of nudges (top and bottom), and make sure we're not putting more than a single grid spacing between them | |
CGFloat belowTitleMargin = [ASPUtil roundToSubPixelPrecision:titleDescenderRoundedToNextGridline + descriptionAscenderRoundedToNextGridline deviceScale:deviceScale]; | |
if (belowTitleMargin > 8.0) { | |
belowTitleMargin = fmod(belowTitleMargin, 8); | |
} | |
self.constraintBelowTitle.constant = belowTitleMargin; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment