iPhone how to write symbol on a label?

2019-01-25 19:56发布

问题:

I am going to develop the iPhone app. But I got stuck with one place. I want to write some symbol on the label from the xib file.

The symbols are not on the keyboard but we can get it by the ASCII value.

e.g: the ACSII value for the character sign "mue" is 230 but how to print that symbol "mue" on the label that i dont know.

So please help me for that.

Thanks in advance.

回答1:

Use whatever editor you like to produce that character, and open your xib in XCode and just copy/paste it in?



回答2:

Use NSUTF8StringEncoding to encode your string.

For example,

NSString *str = [NSString stringWithUTF8String:"your string for encoding"];

[lblName setText:str];

Following function will also help :

- (NSString *) decodedString:(NSString *) originalString {
    NSString *newString = [NSString stringWithUTF8String:[originalString cStringUsingEncoding:[NSString defaultCStringEncoding]]];
    return newString;
}

I suggest to use above function.



回答3:

Press "Command" + "Control" + "Space" will open a special characters menu. Check if the desired symbol is present. If it isn't, click the gear icon, then select the desired category — add it to the list.

See screenshot below



回答4:

I think you mean the character 'µ', yes?

If so, you can simply type it into the label by clicking "option" and "m" on your Macintosh keyboard, when you are editing the label in your XIB.



回答5:

If you can use the unicode number instead, you can do it like this:

NSString *muString = [NSString stringWithFormat:@"%C", 0x03BC];

Write 0x then the unicode number.



回答6:

Open the "Special Characters"-Panel and search for your character. You can find it at the bottom of the edit menu. There is a shortcut for it too, cmd+opt+t

Copy and paste your character from there to your UILabel.

and btw: option + m = µ



回答7:

You can simply type into label by using 'Alt' key + 'm' key on key board, when you are editing the label in your XIB and rest of symbols, you can get easily using 'Alt' key and other keys. You can fix 'Alt' key and change other keys(one by one).