Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Showing Emoji with string in textfield in swift

Tags:

ios

swift

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.

like image 960
Raj Aggrawal Avatar asked Nov 28 '22 14:11

Raj Aggrawal


2 Answers

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

like image 118
shivamkaushik Avatar answered Dec 15 '22 17:12

shivamkaushik


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
like image 26
mdhomer Avatar answered Dec 15 '22 17:12

mdhomer