Pat*_*han 46 iphone objective-c ios xcode4.2
我想在我的应用程序中实现自定义字体.所以我在我的项目源代码中添加了它.我不想以编程方式设置它.我可以通过在xib中设置属性来实现这一点吗?
Raj*_*071 136
将自定义字体添加到项目中,即将字体文件(CALIBRIZ_0.TTF)拖动到XCode项目中.
编辑Info.plist:添加一个新条目,其中包含"应用程序提供的字体"键.
对于每个文件,将文件名添加到此数组

打开字体书中的字体(在finder中双击你的字体)看看真正的文件名是什么,我看到了:

现在将字体设置为标签
yourLabel.font = [UIFont fontWithName:@"Calibri" size:15];
Run Code Online (Sandbox Code Playgroud)
按照这个来获得更多
Piy*_*bey 23
我觉得你搜索不好.
Run Code Online (Sandbox Code Playgroud)How to add CUSTOM fonts:- Steps:- 1. Add your custom font files into your project using XCode as a resource 2. Add a key to your info.plist file called "Fonts provided by application". 3. Make this key an array 4. For each font you have, enter the full name of your font file (including the extension) as items to theUIAppFonts array 5. Save info.plist 6. Now call UIFont *fontCustom = [UIFont fontWithName:@"CustomFontName" size:12]; to get the custom fonts.
注意: -确保字体位于Copy Bundle Resources中.
例如: - 如果您想在应用中使用" Nexa Light"字体,请将"Nexa Light.otf"添加到项目中,然后以这种方式调用.
UIFont *fontCustom = [UIFont fontWithName:@"Nexa Light" size:14];
lblName.font = fontCustom;
Run Code Online (Sandbox Code Playgroud)
Sac*_*hin 11
步骤1:
将字体文件复制到资源文件.确保将其添加到Build Phases设置中的Copy Bundle Resources.
第2步:
在您的Info.plist中,只需在此屏幕下方配置即可

第3步:
使用以下代码访问和使用它:
UIFont *font = [UIFont fontWithName:@"YOUR_FONT" size:10];
Run Code Online (Sandbox Code Playgroud)
iPa*_*tel 11
使用.ttf文件中的字体名称
你也可以从这个链接找到
将此字体名称与其扩展名(OpenScan.ttf)一起添加到.plist文件中之后

将此字体添加到.plist文件后,您可以使用它
[self.txtField setFont: [UIFont fontWithName:@"OpenSans" size:13]];
Run Code Online (Sandbox Code Playgroud)
有关更多信息,请阅读我的答案向iOS应用程序添加自定义字体以查找其真实姓名.
| 归档时间: |
|
| 查看次数: |
49415 次 |
| 最近记录: |