淡出不适合的文本标签字符串的结尾(而不是截断) [英] Fade out end of text label strings that don't fit (instead of truncate)

查看:62
本文介绍了淡出不适合的文本标签字符串的结尾(而不是截断)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不确定淡出"是否正确使用,因为它似乎经常指代动画效果,但我想实现的效果可以在 iPhone 的地址栏中看到Safari 应用程序.当 URL 太长而无法显示时,字符串的结尾会淡出"而不是被..."截断.

I'm not sure if "fade out" is the correct term to use, as it seems to refer to the animation effect a lot, but what I'd like to achieve can be seen in the address bar of the iPhone Safari app. When a URL is too long to display, the end of the string "faded out" rather than truncated with "...".

我认为这可以通过在 XIB 文件中将 Line Breaks 设置从Truncate Tail"更改为Clip",然后使用具有透明度的图像来创建效果来轻松完成.但是设置为剪辑"似乎是在单词的末尾进行剪辑,而不是在单词的中间,甚至是字母的中间,就像在 iPhone 的 Safari 或 Chrome 中看到的那样.这对我来说不是很有效,它实际上给人的印象是文本是完整的,当仔细检查时,用户会发现文本没有意义.

I thought this could be easily done by changing the Line Breaks setting from "Truncate Tail" to "Clip" in the XIB file and then using an image with transparency to create the effect. But setting to "Clip" seems to clip at the end of a word, rather than the middle of a word, or the middle of a letter even, as seen in Safari or Chrome for iPhone. This doesn't quite work for me, and it actually gives the impression that the text is complete, when upon closer inspection, the user will notice that the text doesn't make sense.

淡出"不适合文本标签的字符串的最佳方法是什么?提前致谢.

What's the best way to "fade out" strings that don't fit in text labels? Thanks in advance.

推荐答案

查看适用于 Mac 的 Google 工具箱 GTMFadeTruncatingLabel,这是一个可重复使用的组件,正是这样做的.

Take a look at the Google Toolbox for Mac GTMFadeTruncatingLabel, which is a reusable component that does exactly this.

这篇关于淡出不适合的文本标签字符串的结尾(而不是截断)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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