简体   繁体   English

使用Swift格式化段落文本

[英]Formatting Paragraph Text With Swift

I'm new to coding and am stuck on formatting what I want to write. 我是编码的新手,并且坚持格式化要编写的内容。 I need it formatted with bullet points and spaces. 我需要将其格式化为要点和空格。 The easiest would be to just screenshot the page but I'd rather be able to change the words if necessary in case of changes later. 最简单的方法是仅截取页面截图,但我希望能够在以后进行更改的情况下根据需要更改单词。 Below is an example of what a protocol page looks like. 以下是协议页面外观的示例。 That's what I need. 那就是我所需要的。 Not a big run-on sentence. 这句话没什么大不了的。

How might I be able to accomplish this in Swift? 我怎么能在Swift中完成呢?

Here's an example 这是一个例子 在此处输入图片说明

You have a few options: 您有几种选择:

• You can use a font symbol, like this: • (or an Emoji) inline with text. •您可以使用字体符号,如下所示:•(或表情符号)内联文本。

• Use a customized webview to show stylized content. •使用自定义的Web视图显示风格化的内容。

• Render each line and custom bullet in Quartz. •在Quartz中渲染每一行和自定义项目符号。

You could also use the Unicode code point for the bullet character in your string. 您还可以将Unicode代码点用于字符串中的项目符号字符。

myLabel.text = @"\• This is a list item!";

Format UILabel with bullet points? 用项目符号点格式化UILabel吗?

对于长而复杂的文本,您可以使用HTML和WKWebView或使用NSLayoutManager (如果刚开始,则可能会有些复杂),如《 文本布局编程指南》中所述

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

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