我想在UITextView
中缩进部分文本原件:
Paragraph Here:
Hello World this is just a test.
Hello World this is just a test.
Hello World this is just a test
如何让它像这样显示
Paragraph Here:
Hello World this is just a test.
Hello World this is just a test.
Hello World this is just a test
我不想在开始使用空格,因为如果设备非常小,它会把它弄得一团糟
答案 0 :(得分:1)
如果您想要新行中的每一行,请使用新行。示例代码
in
或者如果你想在UITextView的开头留一点空间然后使用它
let textMessage = "Hello World this is just a test.\nHello World this is just a test.\nHello World this is just a test"
self.textView.text = textMessage
答案 1 :(得分:1)
var textMessage = "Paragraph Here:\nHello World this is just a test.\nHello World this is just a test.\nHello World this is just a test"
textMessage = textMessage.replacingOccurrences(of: "\n", with: "\n\t")
textView.text = textMessage
试试上面的代码。 我希望它可以帮助你。
答案 2 :(得分:0)
我使用“\ t”创建标签。
let string = "\tHello World this is just a test."
答案 3 :(得分:0)
对于其他正在研究此问题的人,我在此博客上找到了解决方案:
https://bendodson.com/weblog/2018/08/09/bulleted-lists-with-uilabel/
“繁重的工作由NSParagraphStyle完成 名为headIndent的属性,它向其中添加固定量的填充 除段落的第一行外的所有内容”