Closed devSC closed 8 years ago
什么问题?
高度计算错误.
怎么错了? 宽度不对还是高度不对?和实际显示相比呢?
高度不正确. 这边我设置的size为:CGSizeMake(200, 100),现在text这么长, 肯定不止1行,但计算下来,只能显示一行.
maximumNumberOfRows 限制为最多显示 2 行。 然后这个计算结果是头 2 行的文字宽高。
这里我font设置的是bold_21.如果是2行, 那最少应该也是42吧?
哦。。 lineBreakMode = NSLineBreakByTruncatingTail; 这一行导致的。 这会阻止文字换行。。
看到了, 感谢.
有如下Code: ` NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc] initWithString:@"It's so huge that I split it into several independent components: YYModel — High performance model framework for iOS. YYCache — High performance cache framework for iOS.YYImage — Image framework for iOS to display/encode/decode animated WebP, APNG, GIF. YYWebImage — Asynchronous image loading framework.YYText — Powerful rich text component for iOS.YYKeyboardManager — Access keyboard view and track keyboard animation."]; attributedText.color = [UIColor whiteColor]; attributedText.font = [UIFont boldSystemFontOfSize:21]; attributedText.lineBreakMode = NSLineBreakByTruncatingTail;
打印结果是:
` 2015-12-17 18:01:27.655 Being[7679:1849388] textBoundingSize: {185, 26},
textBoundingRect: {{0, 0.0048828125}, {184.5087890625, 25.060546875}} ` 不知道那里出问题了.