Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show Emoji in UILabel iOS

I have to show the textview text smily in UILabel.

In the UILabel -

lbl.text = @"Happy to help you \U0001F431;

its showing properly.

In UITextView -

I tried to convert UITextView text in string and then log is -

%F0%9F%99%88%F0%9F%99%89%F0%9F%99%8A

How to encode which i can show in UILabel, anybody please suggest me.

like image 443
San007 Avatar asked May 15 '14 06:05

San007


People also ask

How to use emoji on mac?

Position the cursor in any text field you'd like to insert an emoji, like posting a tweet for example. Hold down the following three keys at the same time: Command+Control+Spacebar. This will bring up the emoji picker. Click the emoji you'd like to use and it'll be inserted where you left your cursor.

How do I add Emojis to Swiftui?

In any app with text editing capability, including Xcode, you can click on the Edit menu, then Emoji & Symbols. You'll see a panel with emoji. Choose any of them and they will appear in your code. Another way is to use the hotkey ⌃⌘Space (ctrl + cmd + space).

How to use emojis on iPhone 11?

1 Tap the text field, then tap the Emoji button or the globe . 2 Use the gray icons at the bottom of the keyboard to switch emoji themes, or swipe left or right to view more. Tap the clock to see emoji that you've ... 3 To change the skin tone of certain emoji, tap and hold an emoji. 4 Tap an emoji to add it to your text field.

How to create interactive text with funny emojis using uilable?

First off, let create an instance of UILable to display on viewport and assign required properties and set of constraints This label will be used to create our interactive text with funny emojis. Next, let's create a collection of emoji UIImage s and default icon sizes to use.

How do I add emojis to my Android keyboard?

Find the emoji keyboard in any app that uses the standard keyboard, like Mail or Messages. To add an emoji: Tap the text field, then tap the Emoji button or the globe. Use the gray icons at the bottom of the keyboard to switch emoji themes, or swipe left or right to view more.

Why don't I see the emoji keyboard?

Don't see the emoji keyboard? 1 Go to Settings > General and tap Keyboard. 2 Tap Keyboards, then tap Add New Keyboard. 3 Tap Emoji. More ...


3 Answers

You can use ⌃ ⌘ Space shortcut to show the symbols panels and just insert the emoji you're looking for directly without unicode:

lbl.text = @"Happy to help you 😺";

(just copy the code above to Xcode if you browser doesn't show the emoji)

like image 70
Sash Zats Avatar answered Sep 17 '22 13:09

Sash Zats


NSString *str = @"Happy to help you \U0001F431";

NSData *data = [str dataUsingEncoding:NSNonLossyASCIIStringEncoding];
NSString *valueUnicode = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];


NSData *dataa = [valueUnicode dataUsingEncoding:NSUTF8StringEncoding];
NSString *valueEmoj = [[NSString alloc] initWithData:dataa encoding:NSNonLossyASCIIStringEncoding];

_lbl.text = valueEmoj;

SWIFT - 3 OR HIGHER

    let str = "Happy to help you \U0001F431"

    let data : NSData = str.dataUsingEncoding(NSNonLossyASCIIStringEncoding)!
    let valueUnicode : String = String(data: data, encoding: NSUTF8StringEncoding)!

    let dataa   : NSData = valueUniCode.dataUsingEncoding(NSUTF8StringEncoding)!
    let valueEmoj : String = String(data: dataa, encoding: NSNonLossyASCIIStringEncoding)!

SWIFT - 4 OR HIGHER

    let str = "Happy to help you \U0001F431"

    let data : NSData = str.dataUsingEncoding(NSNonLossyASCIIStringEncoding)!
    let valueUnicode : String = String(data: data as Data, encoding: String.Encoding.utf8)!

    let dataa   : NSData = valueUnicode.data(using: String.Encoding.utf8)! as NSData
    let valueEmoj : String = String(data: dataa as Data, encoding: String.Encoding.nonLossyASCII)!
like image 32
Bhavesh Nayi Avatar answered Sep 16 '22 13:09

Bhavesh Nayi


On Xcode version 7.2.1, You can use the below shortcut to show the symbols panels and insert the emoji:

shortcut: (pressed the below three keys together)

Ctrl Command Space
like image 29
LuAndre Avatar answered Sep 19 '22 13:09

LuAndre