简体   繁体   English

在固定的UILabel中处理长文本的最佳实践是什么

[英]what is the best practice for dealing with long text in fixed UILabel

i have a table holding custom cells. 我有一张桌子,放着自定义单元格。 in each cell there is a UILabel, which should show a text with a non fixed length. 每个单元格中都有一个UILabel,该UILabel应显示长度不固定的文本。 the label has a maximum size, let's say (150,30). 标签的最大尺寸为(150,30)。 it can show only one line of text. 它只能显示一行文本。

What is the best practice in dealing with long texts?? 处理长文本的最佳做法是什么? should i reduce the size of the font? 我应该减小字体的大小吗? it doesn't look that good, since each row will have a different size.. should i trim the text at the end? 它看起来不太好,因为每一行的大小都不同。.我应该在末尾修剪文本吗? then i'm not displaying everything. 那我就什么都不显示。 is there a simple way of animating the text to slide inside the Label ?? 有没有一种简单的方法可以使文本动画以在Label内滑动?

You could maybe trim the text at the end and also make the UILabel clickable, by adding a transparent button over it. 您可以在其末尾修剪文本,并通过在其上添加透明按钮来使UILabel可单击。 By touching the UILabel you could show an alert with the full text.. Alternatively you could add a button somewhere next to the text that would show the alert. 通过触摸UILabel,您可以显示带有全文的警报。或者,您可以在显示警报的文本旁边添加一个按钮。

ok, so after a lot of tries and errors there isn't a magic answer. 好的,因此经过多次尝试和错误之后,没有一个神奇的答案。

I ended up forcing the text to be of a maximum size, it looks best, and in particular the user experience of long names was bad.. 我最终迫使文本最大,看起来最好,特别是长名称的用户体验很糟糕。

you could create a scrolling text label with: https://github.com/cbpowell/MarqueeLabel.git it didn't look good to my needs, but it can go well for other needs.. 您可以使用以下方法创建滚动文本标签: https : //github.com/cbpowell/MarqueeLabel.git它看起来不符合我的需求,但可以满足其他需求。

decreasing the text size on long labels is also one of the options, but if you have more than one label on the screen and their fonts are of different sizes it looks bad. 减小长标签上的文本大小也是一种选择,但是如果屏幕上有多个标签并且它们的字体大小不同,则看起来很糟糕。

trimming the text is the worst.. 修剪文本是最糟糕的..

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM