简体   繁体   English

如何更改适用于 iPhone 的文本字体?

[英]How to change text font that works in iPhone?

I am working on an appllication where i have to use calculator font for my UITextfield.我正在开发一个应用程序,我必须为我的 UITextfield 使用计算器字体。 I have installed that font in my mac and i have changed font of textfield from nib but it is not working when i check it in iPhone simulator.我已经在我的 Mac 中安装了该字体,并且我已经从 nib 更改了文本字段的字体,但是当我在 iPhone 模拟器中检查它时它不起作用。 The output I want is this我想要的output就是这个在此处输入图像描述

any body have an idea?任何机构有一个想法?

after setting font its result is like设置字体后它的结果就像在此处输入图像描述

Installing the font on Mac is not enough.在 Mac 上安装字体是不够的。 You have to embed the font into your app.您必须将字体嵌入到您的应用程序中。 Here is a tutorial on how to achieve this.这是有关如何实现此目的的教程。 Good Luck:祝你好运:

http://kgriff.posterous.com/45359635 http://kgriff.posterous.com/45359635

Basically it says:基本上它说:

CUSTOM FONTS IN IOS.在 IOS 中定制 FONTS。 Your designer has given you this super snazzy custom font for your app.您的设计师为您的应用程序提供了这种超级时髦的自定义字体。 Now what?!怎么办?!

iOS 4 makes it easy to include custom fonts in your projects. iOS 4 可以轻松地在您的项目中包含自定义 fonts。 Drop the file (CloisterBlack.ttf) into your project.将文件 (CloisterBlack.ttf) 拖放到您的项目中。 Open up your Info.plist file, create a key called UIAppFonts and make it an array.打开 Info.plist 文件,创建一个名为 UIAppFonts 的键并将其设为数组。 Add the filename of the font as a value.添加字体的文件名作为值。

UIAppFonts CloisterBlack.ttf Wherever you want to use the font in your application you can call: UIAppFonts CloisterBlack.ttf 无论你想在你的应用程序中使用字体,你都可以调用:

[UIFont fontWithName:@"CloisterBlack" size:64.0] Hum not quite, when I fired up my application I was met the the same old font - what gives? [UIFont fontWithName:@"CloisterBlack" size:64.0] 嗯,不完全是,当我启动我的应用程序时,我遇到了相同的旧字体 - 什么给出了?

Turns out (in my case) I should not be referencing the font by the value I supplied to my plist file.结果(在我的情况下)我不应该通过我提供给我的 plist 文件的值来引用字体。 I opened my font in Font Book, and the 'name' has a good 'ol space in it.我在 Font Book 中打开了我的字体,“名称”中有一个很好的“ol”空间。

[UIFont fontWithName:@"Cloister Black" size:64.0] Anyway that's 20 minutes I'll never get back. [UIFont fontWithName:@"Cloister Black" size:64.0] 反正那是 20 分钟,我再也回不来了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM