ibireme / YYText

Powerful text framework for iOS to display and edit rich text.
MIT License
8.86k stars 1.7k forks source link

不同字体大小的富文本在iOS10以前的系统上无法垂直居中 #608

Open hangzhoujc opened 7 years ago

hangzhoujc commented 7 years ago

无论直接设NSBaselineOffsetAttributeName,还是通过设yy_baselineOffset,在iOS10以前的系统上都不行,只有在iOS10上可行。

NSMutableAttributedString str1 = [[NSMutableAttributedString alloc] initWithString:@"精华" attributes:@{NSBaselineOffsetAttributeName:@5, NSFontAttributeName:[UIFont systemFontOfSize:11], NSForegroundColorAttributeName:[UIColor redColor]}]; str1.yy_baselineOffset = @5; NSMutableAttributedString str2 = [[NSMutableAttributedString alloc] initWithString:@"从业20年的高端客户经营秘籍" attributes:nil]; str2.yy_color = [UIColor blackColor]; str2.yy_font = [UIFont systemFontOfSize:17]; [str1 appendAttributedString:str2]; YYLabel *l = [[YYLabel alloc] init]; l.frame = CGRectMake(15, 300, self.view.frame.size.width - 30, 46); l.numberOfLines = 0; l.lineBreakMode = NSLineBreakByCharWrapping; l.textVerticalAlignment = YYTextVerticalAlignmentCenter; l.attributedText = str1; [self.view addSubview:l];

WenMingYan commented 7 years ago

请问这个问题解决了吗

hangzhoujc commented 7 years ago

恩,如有问题留下qq

sven713 commented 6 years ago