swift - 如何显示彩色表情符号

标签 swift xcode unicode emoji

我的代码:

let myemoji = "\u{2049}"
let another = "\u{2757}"

Playground 结果:

enter image description here

Unicode U+2049 不会生成像这样的红色表情符号 ⁉️。 这种颜色有什么特别要添加的吗?

最佳答案

一些字符可以显示为“文本”或“表情符号”,并且 “Unicode VARIATION SELECTOR”可用于控制演示。 示例:

print("text presentation:  \u{2049}  \u{25B6}")
print("emoji presentation: \u{2049}\u{FE0F} \u{25B6}\u{FE0F}")

结果:

enter image description here

有关详细信息,请参阅 1.4.3 Emoji and Text Presentation Sequences :

ED-8. text presentation selector — The character U+FE0E VARIATION SELECTOR-15, used to request a text presentation for an emoji character. (Also known as text variation selector in prior versions of this specification.)

ED-9. emoji presentation selector — The character U+FE0F VARIATION SELECTOR-16, used to request an emoji presentation for an emoji character. (Also known as emoji variation selector in prior versions of this specification.)

Variation Selector-16 :

An invisible codepoint which specifies that the preceding character should be displayed with emoji presentation. Only required if the preceding character defaults to text presentation.

关于swift - 如何显示彩色表情符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48534667/

相关文章:

objective-c - Cocoa/Obj-C 简单 XML 文件阅读器 - 需要帮助

ios - Xcode 8 将代码转换为 swift 2.3 不在设备目标中运行

php - 从 HTML 实体转换为 UTF-8

C++ 基础知识(使用其他方法(unicode?)的相同代码)

swift - 如何从另一个 NavigationController 更改 UINavigationBar 的标题

swift - 在 View Controller 之间快速切换

iphone - 创建 IPA, "contains multiple products"

python - 再次出现UnicodeEncodeError(ascii codec无法编码)

swift - 网络连接丢失错误

swift - 台风:从 Storyboard OS X 注入(inject) Controller