Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Showing emoji in a 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.

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

like image 340
AlanL Avatar asked Jul 23 '12 19:07

AlanL


3 Answers

To use Emoji's just press Control+command+space (⌃⌘Space). No need of using unicode for emoji.

like image 105
Ajith Kumar Avatar answered Nov 11 '22 10:11

Ajith Kumar


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];

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

like image 34
Xavi Gil Avatar answered Nov 11 '22 09:11

Xavi Gil


In xcode just go to the top bar and click EDIT > EMOJIS & SYMBOLS and an emoji box will pop up and you can literally add it to any text in the app, even works in the interface builder if you need to add it to the text of a uilabel there.

enter image description here

enter image description here

like image 16
Trianna Brannon Avatar answered Nov 11 '22 11:11

Trianna Brannon