OnkaPlonka OnkaPlonka - 1 year ago 78
iOS Question

How to put an arrow into a UILabel

Hi I'm trying to put an arrow into a UILabel's text but it is not working. I'm trying the following code

NSString *labeltext = @"➜";
label.text = labeltext;

But that makes the app crash!

enter image description here

(if you go to the edit menu and go to special characters then it is the 10th rightwards arrow)


Thanks for your help in advance

Answer Source

Code should be working by just writing the special character directly in the code as written in the question also


but in case it is not working then there are alternative ways to print the special characters in IOS, You need to use Unicode character of this sign , check out this page codes and after getting the code just do like as follows

    UniChar ucode = 0x2794;
    NSString *codeString = [NSString stringWithCharacters:&ucode length:1];
    [label setText:codeString];

OR Just write directly like as follows

label.text=@"\u2794"; // this is the unicode for right arrow

in Swift:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download