I am new to swift development. I need to show the emoji inside the text field and labels. I also need to send them to server because Application is multi-platform.
Asked
Active
Viewed 1.6k times
5
-
http://stackoverflow.com/questions/23670959/how-to-show-emoji-in-uilabel-ios and – iPatel Jul 07 '16 at 06:39
-
5`textField.text = ""` – where is the problem? – Martin R Jul 07 '16 at 07:24
-
Possible duplicate of [UILabel not showing emoji](https://stackoverflow.com/questions/31059988/uilabel-not-showing-emoji) – Raj Aggrawal Oct 27 '17 at 11:40
3 Answers
10
On Xcode version 7.2.1+, you can use the below shortcut to show the symbols panels and insert the emoji:
Shortcut: (press the below three keys together)
Ctrl + Command + Space

aheze
- 24,434
- 8
- 68
- 125

shivamkaushik
- 374
- 1
- 12
9
You can declare a string variable with text and an emoji inside using its unicode number (1F603 is unicode number for an open faced smiley), like so:
let str : String = "Smiley \u{1F603}"
Then with your UITextField/UILabel, set the .text attribute to be the string.
yourTextField.text = str
//or for a UILabel.
yourLabel.text = str

mdhomer
- 490
- 5
- 10
-
-
3Unicode Defination - an international encoding standard for use with different languages and scripts, by which each letter, digit, or symbol is assigned a unique numeric value that applies across different platforms and programs. So yeah, It will be consistent on other platforms. – shivamkaushik Jul 07 '16 at 08:56
-
@shivamkaushik Please give me any source of Unicode to clear out the topic – Raj Aggrawal Jul 07 '16 at 10:37
-
1Here is an extensive list of Emoji codes. Use the five characters after the U+ http://www.unicode.org/emoji/charts/full-emoji-list.html – Ben Jul 15 '20 at 02:23
5
textField.text=@"";
for above Emoji --- put the focus at place of emoji in UITextField
and go to
Edit > Emoji & Symbols in Xcode 7.3 and select what ever emoji you want.
OR
Set Unicode values directly in code:
var string: String = "I want to visit मुंबई. "
var character: Character = ""
Use hexadecimal to set values
var string: String = "\u{61}\u{5927}\u{1F34E}\u{3C0}"
var character: Character = "\u{65}\u{301}"

Dharmesh Kheni
- 71,228
- 33
- 160
- 165

Arjun Singh Baghel
- 135
- 10