首页 > 解决方案 > macOS 上 NSPopover 中的表情符号列表,如 Messages App

问题描述

我想NSPopover在我的 Mac 应用程序中显示一个列出表情符号的应用程序,就像 Apple 的 Messages 应用程序一样:

消息表情符号弹出框

到目前为止,我能想到的是,我可以使用以下方法在我的应用程序中显示字符调色板:

NSApp.orderFrontCharacterPalette(nil)

但这将调色板显示为一个单独的窗口,如下所示:macOS 字符调色板

有谁知道我如何将调色板嵌入到NSPopover我的应用程序中并检索选定的表情符号(类似于 Apple 在 Messages 中的操作方式)?

标签: macosemojiappkitnspopover

解决方案


将您的 textView、textField 或任何其他视图设置为NSApp.orderFrontCharacterPalette(_:).

NSApp.orderFrontCharacterPalette(self.textField)

推荐阅读