在 Xcode 中的 UILabel 上编写印地语
我编写了一个代码,需要在 UILabel 上显示印地文数字。我使用梵文字体来显示该值,但它不起作用。它只是改变了外观,但没有改变语言。
我正在使用:
UIFont *font = [UIFont fontWithName:@"DevanagariSangamMN" size:16];
myLabel.font = font;
但它不起作用。谁能帮我解决这个问题吗?
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.
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你把字体名称弄错了。字体名称是
DevanagariSangamMN
而不是DevanagarSangamMN
(请注意您的名字中缺少“i”)。因此,您的代码应该是:查找有关 iOS 字体的更多信息。我推荐这个网站,它拥有iOS中可用的所有字体
此外,如果您在标签中输入英文字符,您将得到返回的是英文版本而不是印地语翻译。它不会为您进行翻译。使用 DevanagariSangamMN 只允许您显示印地语字符,因为通常使用的 Helvetica 等字体不包含印地语字形。例如:
这将返回英语的“Testing”,而不是印地语。但是,如果你这样做:
那么你会得到“परीक्षण”,这是印地语中的“测试”(我使用谷歌翻译,所以它可能是错误的)。因此,要获得印地语版本 (४) 的数字“4”,您需要执行以下操作:
You have got the font name wrong. The font name is
DevanagariSangamMN
notDevanagarSangamMN
(note the missing 'i' in your name). Your code should therefore be: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:
This will return 'Testing' in English, Not in Hindi. However if you do:
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:
您是否以 unicode 分配
UILabel
文本?试试这个 -are you assigning your
UILabel
text in unicode? Try this -