在Xcode中在UILabel上写印地语 [英] Writing Hindi language on UILabel in Xcode

查看:101
本文介绍了在Xcode中在UILabel上写印地语的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个代码,我需要在UILabel上显示印地文数字。我使用梵文字体来显示该值,但它不起作用。它只是改变了外观而不是语言。

I have written a code where I need to display hindi numbers on the UILabel. I used devanagari font to show that value but it doesn't work. It just changes the look but not the language.

我当时正在使用:

UIFont *font = [UIFont fontWithName:@"DevanagariSangamMN" size:16];
myLabel.font = font;

但它不起作用。任何人都可以帮我这个吗?

But it's not working. Can anyone please help me with this?

推荐答案

你的字体名称有误。字体名称是 DevanagariSangamMN 不是 DevanagarSangamMN (注意你名字中缺少的'i')。因此,您的代码应为:

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;

查找有关iOS字体的更多信息。我建议这个网站,其中包含iOS中可用的所有字体

To find more information about the iOS Fonts. I recommend this website which has all the fonts available in iOS

此外,如果您在标签中键入英文字符,您将收到英文版而非印地文翻译。它不会为您翻译。使用DevanagariSangamMN只允许您显示印地语字符,因为通常使用的Helvetica等字体不包含印地语字形。例如:

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";

这将以英语返回'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 = @"परीक्षण";

然后你会得到'परीक्षण'这是'测试'的印地语(我使用谷歌翻译所以这可能是错的)。因此,要使用印地语版本(4)获得数字'4',您需要执行以下操作:

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 = @"४";

这篇关于在Xcode中在UILabel上写印地语的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆