截断标签的开头 [英] Truncate beginning of label

查看:60
本文介绍了截断标签的开头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个标签( NSTextField ),其文本右对齐.当文本太大而无法显示时,文本的结尾将被截断(在标签的右边缘).就我而言,我实际上想截断文本的开头.如何在Interface Builder或代码中实现此目标?

I have a label (NSTextField) with text aligned right. When the text becomes too large to display, the end of the text is truncated (at the right edge of the label). In my case I would actually want to truncate the beginning of the text. How can I achieve this in the Interface Builder or in code?

现在

| This sentence is to |

所需

| entence is too long |

推荐答案

我不太确定这是否适用于NSTextField,我知道它适用于UILabels,但您是否尝试过:

I'm not quite sure if this works for NSTextFields, I know it does for UILabels, but have you tried :

myTextField.lineBreakMode = NSLineBreakMode.ByTruncatingHead

这篇关于截断标签的开头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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