fix(core): proper line-height calculation (#10642)

This commit is contained in:
Dimitris-Rafail Katsampas
2024-10-31 23:40:23 +02:00
committed by GitHub
parent 4f46815b27
commit ec7fa5d05e
3 changed files with 16 additions and 5 deletions

View File

@ -26,7 +26,8 @@
BOOL isTextView = [self isKindOfClass:[UITextView class]];
if (lineHeight > 0) {
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
paragraphStyle.lineSpacing = lineHeight;
// Note: Avoid using lineSpacing as it will append the height as extra space
paragraphStyle.minimumLineHeight = lineHeight;
// make sure a possible previously set text alignment setting is not lost when line height is specified
if ([self isKindOfClass:[UIButton class]]) {
paragraphStyle.alignment = ((UIButton*)self).titleLabel.textAlignment;
@ -88,7 +89,8 @@
BOOL isLabel = [self isKindOfClass:[UILabel class]];
if (lineHeight > 0) {
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
paragraphStyle.lineSpacing = lineHeight;
// Note: Avoid using lineSpacing as it will append the height as extra space
paragraphStyle.minimumLineHeight = lineHeight;
// make sure a possible previously set text alignment setting is not lost when line height is specified
if ([self isKindOfClass:[UIButton class]]) {
paragraphStyle.alignment = ((UIButton*)self).titleLabel.textAlignment;