且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

UITextView如何截断文字

更新时间:2023-12-05 10:01:28

编写一个单独的方法,该方法计算字符串中有多少个字母,如果有多个预设值,则将其剪切并在末尾附加三个点

Write a separate method that counts how many letters there are in the string and if there are more than some preset value then cut it and append three dots to the end.

此外,如果您不需要在内部编辑信息,请考虑使用UILabels而不是UITextViews,因为UITextViews需要更长的分配和初始化时间,并且通常比UILabels慢.

Also, consider using UILabels instead of UITextViews if you don't need to edit information inside since UITextViews take longer to allocate and init and are generally slower than UILabels.