如何在末尾绘制带有段落截断的非矩形 UILabel? [英] How to draw a non-rectangle UILabel with paragraph truncation at the end?

查看:26
本文介绍了如何在末尾绘制带有段落截断的非矩形 UILabel?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要显示与下图类似的文本正文,并且仅限于红色的非矩形区域.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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆