\ n不在UIlabel工作 [英] \n not working in UIlabel

查看:188
本文介绍了\ n不在UIlabel工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里看到过类似的问题,但仍然可以找出它为什么不起作用。

I've seen similar questions here, but still can figure out why it's not working.

如何添加换行符(换句话说添加新段落)多行UIlabel?

How to add line break (in other words add new paragraph) in multiline UIlabel?

我有一个带有大量文字的标签,

I have a label with a lot of text,

lbl.numberOfLines = 0;
lbl.sizeToFit;

但我仍然得到这样的东西:
有些文字在这里\ nnnd在这里,我想换新行

but I'm still getting something like this: "Some text here\nAnd here I want new line"

谢谢

推荐答案

UILabel赢了尊重\ n,您可以使用option-return(在界面构建器中)强制换行。

UILabel won't respect \n, You can use option-return (in Interface builder) to force where you want a line break.

您可以使用UIWebView代替标签,然后你可以格式化,但你喜欢。
(并将lineBreakMode设置为AngeDeLaMort上面说的。)

You can use a UIWebView in place of the label and then you can format however you like. (And set the lineBreakMode as AngeDeLaMort says above.)

这篇关于\ n不在UIlabel工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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