Created
October 22, 2016 16:41
-
-
Save bdalziel/257abc42cc3458c381aa96917bf11077 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
// 1. We're trying to align the baseline of the description label with a gridline this far from the bottom of the Content Card | |
CGFloat targetBottomMargin = smallMargin; | |
// 2. We need to know how far to nudge the label down. This is a calculation dependent on the UI traits, and is specific to the typography we're using for the description label | |
CGFloat descriptionLabelBaselineAdjustmentHeight = [ASPFontUtil getUITextElementBelowBaselineHeight:ASPUITextElementContentCardDescription traitCollection:contextTraitCollection]; | |
// 3. Font measurements aren't nice round numbers. I have a utility to round floats to numbers the UI can resonable render at (sub pixel), which is dependent on device scale | |
CGFloat bottomMargin = [ASPUtil roundToSubPixelPrecision:(targetBottomMargin - descriptionLabelBaselineAdjustmentHeight) deviceScale:deviceScale]; | |
// 4. Use our dynamically adjusted bottom margin and hope it works | |
self.contentCard.layoutMargins = UIEdgeInsetsMake(smallMargin, gutterWidth, bottomMargin, gutterWidth); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment