iPhone 项目符号列表
有没有办法在 iPhone 中制作项目符号列表?
如果您将项目符号列表复制并粘贴到 IB 中的 UITextView 中,那么它就会显示出来。有没有办法以编程方式执行此操作?
谢谢
汤姆
Is there any way to make a bullet point list in iphone?
If you copy and paste a bullet point list into a UITextView in IB then it shows up. Is there anyway to do this programatically?
Thank you
Tom
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
“项目符号”字符位于 Unicode 代码点 U+2022。您可以在带有
@"\u2022"
或[NSString stringWithFormat:@"%C", 0x2022]
的字符串中使用它。“换行”字符位于 Unicode 代码点 U+000A,并用作 UIKit 的换行符。您可以在带有
@"\n"
的字符串中使用它。例如,如果您有一个字符串数组,您可以使用如下内容创建项目符号列表:
它不会像“正确的”文字处理器那样缩进行。如果您的列表项包含换行符,就会发生“坏事”(但您期望什么?)。
(Apple 不保证“\uXXXX”转义在 NSString 文字中起作用,但实际上,如果您使用 Apple 的编译器,它们会起作用。)
The "bullet" character is at Unicode code point U+2022. You can use it in a string with
@"\u2022"
or[NSString stringWithFormat:@"%C", 0x2022]
.The "line feed" character is at Unicode code point U+000A, and is used as UIKit's newline character. You can use it in a string with
@"\n"
.For example, if you had an array of strings, you could make a bulleted list with something like this:
It won't indent lines like a "proper" word processor. "Bad things" will happen if your list items include newline characters (but what did you expect?).
(Apple doesn't guarantee that "\uXXXX" escapes work in NSString literals, but in practice they do if you use Apple's compiler.)
据我所知,在 iPhone 上实现此目的(以及几乎任何其他格式化的富文本)的唯一方法是使用 UIWebView 并插入如下 HTML 代码:
In response to your comment, UIWebViews can be "beautified" by以下代码:
我还没有提交这个,但我想它应该是“AppStore 安全的”。
As far as I know the only way to achieve this (and almost any other formatted rich-text) on the iPhone is to use a UIWebView and insert HTML-Code like this:
In response to your comment, UIWebViews can be "beautified" by the following peace of code:
I haven't submitted this yet but I guess it should be "AppStore safe".
Swift-5
只需用 Swift 编写 @tc 答案
Swift-5
Just writing the @tc answer in Swift
结果:
result: