How to draw a non-rectangle UILabel with paragraph truncation at the end?

五迷三道 提交于 2019-12-13 04:46:28

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/17981211/how-to-draw-a-non-rectangle-uilabel-with-paragraph-truncation-at-the-end

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!