Skip to content

Instantly share code, notes, and snippets.

@bdalziel
Created October 22, 2016 16:56
Show Gist options
  • Save bdalziel/92de07e051d334fbd2560ce78f4460fb to your computer and use it in GitHub Desktop.
Save bdalziel/92de07e051d334fbd2560ce78f4460fb to your computer and use it in GitHub Desktop.
+ (CGFloat)getUITextElementAboveBaselineHeight:(ASPUITextElement)element traitCollection:(UITraitCollection *)contextTraitCollection {
ASPUITextStyle elementTextStyle = [self mapUIElementToStyle:element elementVariation:ASPUITextElementVariationDefault];
UIFont *font = [ASPFontUtil getUIFont:elementTextStyle traitCollection:contextTraitCollection];
CGFloat lineHeightMultiple = [self getUILineHeightMultiple:elementTextStyle font:font traitCollection:contextTraitCollection];
CGFloat lineHeightAdjustment = 0.0;
if (lineHeightMultiple != 1) {
lineHeightAdjustment = (font.lineHeight - (font.lineHeight * lineHeightMultiple))/2;
}
return font.ascender - lineHeightAdjustment;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment