[英]UILabel word wrap and slashes
I have a multiple lines UILabel. 我有多行UILabel。 The text contains slash ("/") character.
文本包含斜杠(“ /”)字符。 Usually slash is a not breaking character.
通常,斜杠是不间断的字符。 But UILabel handles it as a breaking one.
但是,UILabel将其作为突破性解决方案。 How to make it non-breakable?
如何使其不易碎?
Example 例
textLabel.lineBreakMode = UILineBreakModeWordWrap;
textLabel.numberOfLines = 2;
textLabel.text = @"Some text with/slash";
This code is rendered as: 此代码呈现为:
Some text with/
slash
Should be rendered as: 应该呈现为:
Some text
with/slash
For Slash, use this: 对于Slash,请使用以下命令:
textLabel.text = @"Some text with\/slash";
For avoiding word wrap in label, use this; 为了避免自动换行,请使用此标签。
[textLabel sizeToFit];
Update: 更新:
Below comment suggests that I misunderstood the problem here.. 以下评论表明我在这里误解了这个问题。
Anyhow, if you want to print it in two lines, use next line carriage ..(/r) 无论如何,如果要分两行打印,请使用下一行的行..(/ r)
textLabel.text =@"Some text \r with/slash";
Working as you wanted.. :) 根据需要工作.. :)
Let me know if any info needed.. :) 让我知道是否需要任何信息.. :)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.