如何在末尾绘制带有段落截断的非矩形 UILabel? [英] How to draw a non-rectangle UILabel with paragraph truncation at the end?
问题描述
我需要显示与下图类似的文本正文,并且仅限于红色的非矩形区域.Rob 对.您可以指定文本的字体大小和最大大小.
您还可以使用 NSString::sizeWithFont:minFontSize:actualFontSize:forWidth:lineBreakMode:
方法计算最小字体大小.
I need to show a body of text similar to the one shown below and limited to the red non-rectangular area. Rob's answer to this question pretty much answers my question as well, but I also need to truncate at tail of the paragraph when the text is too long.
Extra question: is it also possible to set minimum font size similar to UILabel?
Try using NSString::sizeWithFont:constrainedToSize
method which is documented here. You can specify the fontsize and maximum size for the text.
You can also calculate the minimum font size using NSString::sizeWithFont:minFontSize:actualFontSize:forWidth:lineBreakMode:
method.
这篇关于如何在末尾绘制带有段落截断的非矩形 UILabel?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!