How to draw a non-rectangle UILabel with paragraph

2019-08-24 02:03发布

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?

enter image description here

1条回答
等我变得足够好
2楼-- · 2019-08-24 02:47

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.

查看更多
登录 后发表回答