Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting a normal looking unicode down arrow in a UILabel like this ⬇

I would like to get a down arrow to display inside a UILabel. Specifically ⬇ Unicode: U+2B07. This is show sort order on a column header.

I have seen the code to get unicode characters to display and when I use it for the symbol above it doesn't display as expected but rather comes up with a blue down arrow with gloss.

Has anyone seen this?

like image 200
kyleplattner Avatar asked Mar 27 '13 23:03

kyleplattner


2 Answers

Displaying some characters as "Emojis" is a feature which is e.g. (controversially) discussed here: https://devforums.apple.com/message/487463#487463 (requires Apple Developer login). This feature was introduced in iOS 6.

A solution (from https://stackoverflow.com/a/13836045/1187415) is to append the Unicode "Variation selector" U+FE0E, e.g.

self.myLabel.text = @"\u2B07\uFE0E";
// or:
self.myLabel.text = @"⬇\uFE0E";

Note that on iOS <= 5.x, the Variation selector is not necessary and must not be used, because iOS 5 would display it as a box.

In Swift it would be

myLabel.text = "⬇\u{FE0E}"
like image 139
Martin R Avatar answered Nov 10 '22 09:11

Martin R


If you're seeing the blue arrow with gloss, you have the right character, but it's showing one of the emoji-style characters. Try changing the font of your UILabel to something like Arial Unicode MS.

Edit After a little testing, it looks like changing the font doesn't actually work. It keeps displaying the glossy arrow. It's probably better to go with the suggestion of the other answer and use a different glyph, like \u2193, which does work:

[nameLabel setText:@"\u2193"];

enter image description here

like image 21
nevan king Avatar answered Nov 10 '22 10:11

nevan king