Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 772
OnkaPlonka Avatar asked Dec 07 '22 09:12

OnkaPlonka


1 Answers

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

label.text=@"➜";

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:

lable.text="\u{2794}" 
like image 69
nsgulliver Avatar answered Dec 20 '22 06:12

nsgulliver