UILabel看到最右边的内容 [英] UILabel see rightmost content
问题描述
通常,当我在标签中放入字符串时,标签尺寸之后的内容将显示为"...".我需要换个角度看. IE.当内容超过时,我需要显示标签的最右边内容,而最左边的内容应显示在"..."中.
Normally, when I put a string in my label, the contents that go after the label's dimension will be displayed as "...". I need to see this the other way. ie. When the contents exceed, I need to display the rightmost contents of my label and the left most contents should be displayed in "...".
即对于字符串"UILabel看到最右边的内容"
i.e. For a string "UILabel see rightmost content"
而不是显示"UILabel see ri ..."
Instead of displaying "UILabel see ri..."
我需要"...最重要的内容"
I need "...ightmost content"
目前,我是通过根据标签的宽度手动编辑字符串来实现的.还有其他办法吗?
For now, I'm doing this by manually editing the string in-accordance with the width of the label. Is there any other way?
推荐答案
将UILabel的lineBreakMode设置为NSLineBreakByTruncatingHead.
Set the lineBreakMode of the UILabel to NSLineBreakByTruncatingHead.
[myLabel setLineBreakMode: NSLineBreakByTruncatingHead];
这篇关于UILabel看到最右边的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!