Writing Hindi language on UILabel in Xcode
I have written a code where I need to display hindi numbers on the UILabel. I used devanagari font t开发者_开发知识库o show that value but it doesn't work. It just changes the look but not the language.
I was using:
UIFont *font = [UIFont fontWithName:@"DevanagariSangamMN" size:16];
myLabel.font = font;
But it's not working. Can anyone please help me with this?
You have got the font name wrong. The font name is DevanagariSangamMN
not DevanagarSangamMN
(note the missing 'i' in your name). Your code should therefore be:
UIFont *font = [UIFont fontWithName:@"DevanagariSangamMN" size:16];
myLabel.font = font;
To find more information about the iOS Fonts. I recommend this website which has all the fonts available in iOS
Also, if you type English characters into the Label, you will get returned the English version NOT the Hindi translation. It doesn't do the translation for you. Using the DevanagariSangamMN only allows you to show the Hindi Characters because the fonts such as Helvetica which are normally used do not include the Hindi glyphs. For example:
UIFont *font = [UIFont fontWithName:@"DevanagariSangamMN" size:16];
myLabel.font = font;
myLabel.text = @"Testing";
This will return 'Testing' in English, Not in Hindi. However if you do:
UIFont *font = [UIFont fontWithName:@"DevanagariSangamMN" size:16];
myLabel.font = font;
myLabel.text = @"परीक्षण";
Then you will get 'परीक्षण' which is the Hindi for 'Testing' (I used Google Translate so it could be wrong). So to get the number '4' with the Hindi version (४), you need to do the following:
UIFont *font = [UIFont fontWithName:@"DevanagariSangamMN" size:16];
myLabel.font = font;
myLabel.text = @"४";
are you assigning your UILabel
text in unicode? Try this -
myLabel.text = [NSString stringWithFormat:@"String with unicode %C", 0x207F];
精彩评论