UILabel看到最右边的内容 [英] UILabel see rightmost content

查看:74
本文介绍了UILabel看到最右边的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常,当我在标签中放入字符串时,标签尺寸之后的内容将显示为"...".我需要换个角度看. 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屋!

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