I am trying to add and use a font within my app. I've followed this post for reference but I can't get it to work.
I've added the font Frutiger95UltraBlack.ttf
as a supporting file and then added it to my {app-name}-Info.plist.
Then tried to use it in my app delegate to change my UINavegationBar
but nothing happens.
What am i missing??
[[UINavigationBar appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor whiteColor], UITextAttributeTextColor,
[UIFont fontWithName:@"Frutiger95UltraBlack" size:16.0], UITextAttributeFont,nil]];
(从我上面的评论:) [UIFont fontWithName:...]
需要字体的PostScript名称作为参数,可能与文件名不同。
make sure that your font is in your Copy Bundle Resources.
if we not adds font to target then sometimes it happens that your font not automatically adds in Copy Bundle Resources.
also make sure that your font name is same that you have used. you can make this sure by opening font in fontBook.
if you have different fonts like Regular/Bold/italic,then you have to attach this name to your font name like this- Frutiger95UltraBlack-Bold
install your font on mac system.iterate your all fonts programatically , write NSLog for fontName, by this way you can make sure the name of font ie PostScriptName.
Just an FYI, UITextAttributeTextColor
and UITextAttributeFont
were deprecated in iOS 7.0.
Instead replace UITextAttributeTextColor
with NSForegroundColorAttributeName
and UITextAttributeFont
with NSFontAttributeName
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.