Xcode 8 custom font doesn't show up in interface builder
Try Below Steps: Code tested in Swift 3
.
Step 1: Add Your custom font into your project( Make sure Add to Target
ticked).I am using "PermanentMarker.ttf","Pecita.otf" and "AROLY.ttf" font as a test font.
Note: Supporting font Type ttf and otf (Both font types should work)
Step 2: Modify the application-info.plist file.
Add the key "Fonts provided by application" in a new row and add "PermanentMarker.ttf" as new item in the Array "Fonts provided by application".
Your plist should looks like this
Now the font will be available in Interface Builder. To use the custom font in code we need to refer to it by name, but the name often isn’t the same as the font’s filename
Now, You can access the Custom Font from your viewController. I am testing the font by placing a UIlabel to the Storyboard like below.
Update 2: Working Solution
After, imported your custom font and updated your plist
.selectlabel
from your storyBoard
,goto Attributes Inspector
under Label
>Text type
> select to Attributed
and choose your custom font
from the list.
Output:
Update 1
If your custom font still not listed in Xcode font list
.check the related link to your issue
http://codewithchris.com/common-mistakes-with-adding-custom-fonts-to-your-ios-app/
custom font not displaying on some simulator
Note: Still,You can assign BebasNeue
or custom font
programatically to your label or button etc. even its not showing in your interface Builder
.If you having trouble setting font to your object programatically.try below method.
Assign font to UILabel:
label?.font = UIFont(name: "BebasNeue", size: 35) // Set to any size
Assign font to UIButton:
button.titleLabel?.font = UIFont(name: "BebasNeue", size: 35)
Assign font to UITextField:
textField.font = UIFont(name: "BebasNeue", size: 25)
Assign font to UINavigationBar:
navigationController?.navigationBar.titleTextAttributes = [NSFontAttributeName: UIFont(name: "BebasNeue", size: 25)!, NSForegroundColorAttributeName: UIColor.red]
Assign font to UIToolBar:
UIBarButtonItem.appearance().setTitleTextAttributes([NSFontAttributeName: UIFont(name: "BebasNeue", size: 25.0)!], for: UIControlState.normal)
Output:
Custom font seen in Interface builder but not in code in iOS project
You're going to kick yourself...
In your plist info file, you have:
`Quicksand-Dash.otf`
but the file you added is named:
`Quicksand_Dash.otf`
underscore not hyphen
Either rename your file, or edit the plist entry, and you'll see your font.
Debug console output:
family: Quicksand
name: Quicksand-BoldItalic
name: QuicksandDash-Regular
name: Quicksand-Bold
Here is a plain single-view project that works fine for me - on both Simulator and Device. (I have not added the fonts to OS X, only to my project):
https://github.com/DonMag/Quicksand
Just for setup reference:
Custom fonts in Interface Builder
Yes, Marrius is right. In Xcode 6, you neither need to use extra software nor to set Font in Code files. Just add your font files in your project along with other files. And Interface builder will display the added fonts in the Custom Font List.
And the most amazing thing is, xcode 6 shows the applied font instantly in IB. This is the great addition by Apple.
Also make sure to add this key "Fonts provided by application" in your project's info.plist and provide your font file names to see the effect in devices.
Using custom fonts in interface builder
I have also this problem in Xcode 4. In my program, there are lots of UILabel
which have no IBOutlets
so I do in that way;
First, subclass the UILabel
to CustomFontLabel
Then, override the "awakeFromNib
" method
@implementation CustomFontLabel
- (void)awakeFromNib {
[super awakeFromNib];
self.font = [UIFont fontWithName:@"CustomFontName" size:self.font.pointSize];
}
@end
Finally, in Interface Builder > Identity Inspector change class to CustomFontLabel
.
Custom Fonts only available when set in Interface Builder
When I try to use it programmatically it doesn't work, and it doesn't show up when I print out a list of available fonts
This proves that you have not in fact included it properly in the target and the Info.plist.
The reason it seems to work in IB is that this font is also present on your computer. But in fact if you were to run this app on your device, you would see that even setting the font in IB is not working.
Your font is Special Elite. As you can see, I have it visible here in my running app:
Here's the code that I used:
let lab = UILabel()
lab.text = "This is a test"
lab.font = UIFont(name:"SpecialElite-Regular", size:18)
lab.sizeToFit()
lab.frame.origin = CGPointMake(100,100)
self.view.addSubview(lab)
So you see, it is possible to refer to this font in code — if it is loaded properly. You are evidently not loading it properly. It's not in your app bundle, or it's not in the copy build phase, or it's not correctly listed in your Info.plist.
(Of course there's always a possibility that you're calling [UIFont fontWithName:size:]
with a bad value for the name or for the size.)
iOS setting custom font in interface builder does not work on device
Steps which are done for Font is correct, but as per my understanding 2 things are there first is Xcode displays fonts which are found in the Mac OS or in your system, not on the actual iOS device. Before selecting a font, you should make sure it is available on iOS devices. and second is when we edit text in xib,custom Fonts appear, but at runtime it will not get applied.
So it is better that you apply font pragmatically.
http://iosfonts.com/ , http://support.apple.com/en-in/HT202771 or even trial and error can help.
Custom Fonts not showing on Xcode 11 (macOS Catalina)
Unfortunately, the only solution for me was a fresh install of mac os catalina. Now everything works correctly in xCode interface builder.
Related Topics
Animating/Moving Views Under Usage of Autolayout
Avcapturesession Audio Doesn't Work for Long Videos
Nsinternalinconsistencyexception, Reason: Could Not Load Nib in Bundle
Swift - Compressing Video Files
Create PDF with Multiple Pages
Firebase Chat Push Notifications
Storyboard Segues Causing Memory Leaks
Uitextfield -Webview No Longer Supported
Fbsdkloginmanager Loginwithpublishpermissions Always Returns Iscancelled=Yes
Split View Controller Must Be Root View Controller
How to Call a View Controller Programmatically
Code Signing Is Required for Product Type Unit Test Bundle in Sdk iOS 8.0
iOS 7 and Later: Set Status Bar Style Per View Controller
Save and Retrieve Value via Keychain
Atos and Dwarfdump Won't Symbolicate My Address
Disable Bitcode for Project and Cocoapods Dependencies with Xcode 7