How to add custom ttf fonts to iphone application?

倾然丶 夕夏残阳落幕 提交于 2019-12-06 07:52:37

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/6608573/how-to-add-custom-ttf-fonts-to-iphone-application

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!