如何向 iPhone 应用程序添加自定义 ttf 字体?
我在向 iPhone 应用程序添加字体时遇到问题 我想知道如何做到这一点,让我指定我没有使用 IB,并且我继承了 UILabel 并制作了该新类的标签,
请帮助我, 我已经下载了 ttf 并想在我的应用程序中使用, 我将“应用程序提供的字体”添加到我的应用程序中,然后添加带有 ttf 扩展名的字体名称,但仍然不起作用,我该怎么办?
@implementation RRSGlowLabel
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if(self != nil) {
self.glowOffset = CGSizeMake(0.0, 0.0);
self.glowAmount = 0.0;
self.glowColor = [UIColor clearColor];
[self setFont: [UIFont fontWithName: @"DS-DIGI" size: self.font.pointSize]];
}
return self;
}
其中 DS-DIGI.ttf 是我的字体,添加了 tou resources forlder, RRSGlowLabel是UILabel的继承类,现在我该怎么办?
I have problem of adding fonts to my iphone application
I want to know how to do it, and let me specify that I am not using IB and I have inherited the UILabel and making label of that new class,
Please Help me out,
I have downloaded the ttf and want to use in my app,
I added "Fonts Provided by application" to my app and then added the font name with ttf extension, but still didn't work, what should I do ?
@implementation RRSGlowLabel
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if(self != nil) {
self.glowOffset = CGSizeMake(0.0, 0.0);
self.glowAmount = 0.0;
self.glowColor = [UIColor clearColor];
[self setFont: [UIFont fontWithName: @"DS-DIGI" size: self.font.pointSize]];
}
return self;
}
Where DS-DIGI.ttf is my font, added tou resources forlder,
and RRSGlowLabel is inherited class of UILabel, now what should I do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为了在 fontWithName 调用中调用字体,该字符串应该是 Mac 的“字体簿”应用程序中显示的字体名称,而不是引用的字体文件的实际文件名
In order to call the font in your fontWithName call, the string should be the name of the font as it is displayed in the Mac's 'Font Book' app, and not the actual filename of the referenced font file