简体   繁体   English

UILabel不换行尾随空白

[英]UILabel not line breaking trailing whitespace

I have a multi line UILabel that I am trying to re-size so it fits the text. 我有一个多行UILabel,我正在尝试调整其大小以使其适合文本。 This works fine for just text, but I'm also adding in whitespace to give me space to add images in the text. 这仅适用于文本,但我还要添加空格,以便给我空间在文本中添加图像。 When the text ends with the whitespace for these images, the label doesn't word wrap the whitespace, Here's a couple screenshots, one with just text that is what I'm trying to achieve, and one with images where you can see that the label doesn't wrap to a second line. 当文本以这些图像的空白结尾时,标签不会自动换行,这是几个屏幕截图,其中一个是我要实现的文本,另一个是图像,您可以看到标签不会换行。

在此处输入图片说明在此处输入图片说明

In the second image, the text being assigned to the label is just about 40 spaces, and it won't word wrap, any suggestions on how I can do this? 在第二个图像中,分配给标签的文本仅约40个空格,并且不会自动换行,有关如何执行此操作的任何建议?

As maddy mentioned, it's a bad idea to use space for breaking the line. 正如妈妈所说,利用空间来打破界限是一个坏主意。

Using \\n instead of space will give you the desired result. 使用\\n代替空格将为您提供所需的结果。

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

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