[英]Italic Font Is Not Working on XCode
我将我的ttf字体(ABeeZee-Italic.ttf)从Google WebFonts复制到支持文件中并添加到plist中:
并为我的Label指定tag = 4:
因为我有这个代码将字体嵌入UILabel:
for (UILabel *customLabel in [[self view] subviews]) {
if (customLabel.tag == 1) {
[customLabel setFont:[UIFont fontWithName:@"Raleway-ExtraLight" size:21]];
} else if (customLabel.tag==2){
[customLabel setFont:[UIFont fontWithName:@"ABeeZee-Regular" size:14]];
} else if (customLabel.tag==3){
[customLabel setFont:[UIFont fontWithName:@"ABeeZee-Regular" size:11]];
} else if (customLabel.tag==4){
[customLabel setFont:[UIFont fontWithName:@"ABeeZee-Italic" size:12]];
}
}
它的工作就像一个魅力,但斜体字体没有加载到我的iPod(iOS 6.1.3)。 标签4的UILabel是iOS系统字体。 不是ABeeZee-Italic。
我试图更改标签号,但也失败了。 是否有任何特定要求将非常规字体嵌入到iOS中?
谢谢
UPDATE @iPatel回答:这是我的FontBook的样子,它有相同的名字......
在“FontBook”中查看字体的真实姓名(ABeeZee-Italic) ? 并写入“FontBook”中的字体名称。
并使用这样的
[myLabelName setFont: [UIFont fontWithName:@"Font Name From Font Book" size:32]];
有关如何在应用中添加自定义字体的详细信息。 然后阅读本答案。
编辑:
也试试
可能会有所帮助:)
你可以用两种方式做到这一点。
使用ttf文件
[customLabel setFont:[UIFont fontWithName:@"Raleway-ExtraLight.ttf" size:21]];
要么
使用字体名称
[customLabel setFont:[UIFont fontWithName:<Name of Raleway-ExtraLight> size:21]];
在你的情况下,只需在setFont:
添加.ttf setFont:
else获取字体名称,如下图所示。
只需右键单击.ttf文件>获取信息>全名(您的字体名称。您可以在setFont中将此名称用作字体名称)
编辑
在此处检查全名并将其粘贴到您的代码中。
[customLabel setFont:[UIFont fontWithName:@"ABeeZee Italic" size:21]];
编辑1
可能是您需要注册字体 。 只是尝试注册和检查。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.