在UILabel中展示表情符号? [英] Showing emoji in a UILabel?

查看:333
本文介绍了在UILabel中展示表情符号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不确定我在这里缺少什么,搜索没有帮助我。我想在UILabel中显示表情符号字符,而这不是这样:

Not sure what I'm missing here, and searching hasn't helped me. I want to display emoji characters in a UILabel, and this isn't doing it:

UILabel *label = [[UILabel alloc] init];
label.font = [UIFont fontWithName:@"AppleColorEmoji" size:16.0];
label.text = [NSString stringWithFormat:@"%C", 0x1F431];
// ... etc.

与其他非字母unicode字符一起使用,例如国际象棋棋子,但不是我试过的任何表情符号。

Works fine with other non-letter unicode characters, e.g. chess pieces, but not with any emoji characters that I have tried.

推荐答案

你可能没有使用正确的表情编码字符。例如,在你的例子中,我认为你正在寻找这样的东西:

You are probably not using the correct encoding for your emoji characters. For instance in your example I think you are looking for something like this:

label.text = [NSString stringWithFormat:@"%C", 0xe04f];

看看 this 表格可以获得你需要的编码。

Have a look at this table to get the encodings you need.

这篇关于在UILabel中展示表情符号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆