NSLineBreakByWordWrapping在第一行上但是NSLineBreakByTruncatingTail在第二行上吗? [英] NSLineBreakByWordWrapping on First Line but NSLineBreakByTruncatingTail For Second Line?

查看:743
本文介绍了NSLineBreakByWordWrapping在第一行上但是NSLineBreakByTruncatingTail在第二行上吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能吗?

我想有两行标签。在第一行上,我希望它包含所有单词。但是对于第二行,如果文本太长,我希望它被尾部截断并在其后添加省略号 ...

I want to have a two line label. On the first line, I want it to wrap on words. But for the second line, if the text is too long, I want it to truncate by tail and add the ellipses "..." after.

有任何最简单的方法吗?

Any ideas on the simplest way to do this?

推荐答案

在我的评论中,我错了关于换行模式。如果仅拖出一个UILabel,则默认的换行符是截尾。如果将标签的高度提高两倍,并将行设置为2,则文本将自动换行,如果第二行太长,则会显示省略号。没必要做任何花哨的事情。

In my comment I was wrong about the line break mode. If you just drag out a UILabel, the default line break is Truncate Tail, which is what you want. If you make the label twice as high, and set the lines to 2, the text will wrap, and if too long for the second line, it will show the ellipsis. No need to do anything fancy.

这篇关于NSLineBreakByWordWrapping在第一行上但是NSLineBreakByTruncatingTail在第二行上吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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