Mohammad Alikhani
Mohammad Alikhani

Reputation: 191

custom fonts in xcode 7 and adaptive layout

So I'm running into a problem with custom fonts using Xcode 7 with adaptive layout. It's kind of strange. Basically, the custom fonts appear in the storyboards and preview but do not display on the actual devices when I run the app.

i have this problem just with custom fonts, I have the fonts correctly installed. That is not the problem. I have checked that repeatedly. The font shows up in the label's attributes inspector. I select the font from the list of custom fonts from the attributes inspector. The font appears in the storyboard. But when I run... no custom

Upvotes: 1

Views: 402

Answers (3)

Mohammad Alikhani
Mohammad Alikhani

Reputation: 191

I solve this problem with building a custom UI Elements

@IBDesignable class ExUITextField: UITextField {

@IBInspectable var fontName: String = "yourCustomFont" {
    didSet {
        self.font = UIFont(name: fontName, size:self.font!.pointSize)
    }
}

override func layoutSubviews() {
    super.layoutSubviews()
    self.font = UIFont(name: fontName, size:self.font!.pointSize)
}

Upvotes: 0

NRitH
NRitH

Reputation: 13903

It sounds like your fonts aren't being bundled with your app. You've already ensured that the fonts are installed in your project, but you also have to make sure that they're among the resources that are included for your build target.

Upvotes: 0

Muhammad Junaid Butt
Muhammad Junaid Butt

Reputation: 464

Make sure that fonts are properly added in the Xcode project and include them in Info.plist file.

<key>UIAppFonts</key>
<array>
    <string>Colaborate-Bold.otf</string>
    <string>SourceSansPro-Regular.otf</string>
    <string>SourceSansPro-Semibold.otf</string>
</array>

enter image description here

Here is the link about Common Mistakes with Custom Fonts:

http://codewithchris.com/common-mistakes-with-adding-custom-fonts-to-your-ios-app/

Hope it will work for you.

Upvotes: 1

Related Questions