Display Emoji icons in Mac app

試著忘記壹切 提交于 2019-12-13 02:18:41

问题


I want the user to have easy access to Emoji icons in a small chat I am making for the company I'm working at. Therefore, I want to make a panel which shows the available Emoji icons. To do this, I am using an NSCollectionView. Now, I need to pass a string which is shown in an NSTextField. This string must contain one Emoji icon.

I can't figure out how to write this Emoji icon in unicode in a string. Everything I have tried just shows a strange symbol instead of the icon.

Can anyone tell me, how I can put an Emoji icon into an NSString?


回答1:


📱 You want emoji 😄?

🐷🐻🐨🐸 They're in Unicode now 🐸🐨🐻🐷

If you open up the 💻Character Viewer💻 you can actually paste them directly into your source code. If you'd rather, you can encode them in hexadecimal (\U0001F431 for cat face) by looking them up in the Unicode code charts (especially the chart for the U+1F300 block).

If you want to make sure they appear in color, you'll need to select the "Apple Color Emoji" font for the Emoji. You can use NSAttributedString to set the font on a per-character basis.



来源:https://stackoverflow.com/questions/11211551/display-emoji-icons-in-mac-app

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!