【发布时间】:2014-02-11 09:13:48
【问题描述】:
我有一个宽度有限的标签,我需要它来自动调整字体大小以适应文本。 因为我需要给文本加下划线,所以我给这个标签分配了一个属性字符串:
[_commentsLabel setAttributedText:[[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"%d comments", [comments count]] attributes:@{NSUnderlineStyleAttributeName : @(NSUnderlineStyleSingle)}]];
如您所见,cmets 的数量将定义文本的长度。但是由于某种原因,文本并没有缩小。最小字体比例设置为 0.1 并选中 Tighten Letter Spacing。
我认为它可能与我正在使用的自定义字体有关,但即使使用系统默认字体,文本也会被剪裁。
【问题讨论】:
标签: ios uilabel nsattributedstring shrink