Showing emoji in a UILabel?

前端 未结 5 1405
花落未央
花落未央 2020-12-13 04:50

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 =         


        
相关标签:
5条回答
  • 2020-12-13 05:27

    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.

    0 讨论(0)
  • 2020-12-13 05:28

    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

    0 讨论(0)
  • 2020-12-13 05:41

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

    0 讨论(0)
  • 2020-12-13 05:50

    The unicode 6.1 encodings work as well, but you would have to specify them like this:

    label.text = @"\U0001F431";
    
    0 讨论(0)
  • 2020-12-13 05:52

    In Swift you can do:

    label.text = "                                                                    
    0 讨论(0)
提交回复
热议问题