Issues with changing font for UILabel using custom fonts (programatically)

0 Mark L · February 25, 2015

I'm having some trouble changing the font of my UILabel through code.

Here's what I did when I added my custom fonts to the project:

1. made a folder/group in my project called "Fonts"

2. added my fonts to that group. (I made sure both the project and "Projetname Tests" was checked as targets)

3. I checked my project file, -> Build phases -> Copy Bundle resources that the fonts were in there, which they are.

4. I went to my Plist. and added the group called "Fonts provided by Application", in there I added an item for all my fonts, and changed the strings to the font names

and lastly here's the code that I tried changing the font of a simple label with:

var label = UILabel(frame: CGRectMake(100, 70, 200, 21))
label.text = "BE ON THE"
label.font = UIFont(name: "Babas Neue-Bold", size: 106)

The label shows up when I run the app, but neither the size or the font changes.

if anyone wants to check the fontnames are correct, here's the font I'm trying to use:

Lastly, I just want to quickly mention that I am fully able to change the font of any labels to my custom fonts using storyboard. But I cannot get it working through code. :/

Hopefully someone here can help me out :)

Post a Reply


Oldest  Newest  Rating
0 Mark L · February 26, 2015
Nevermind I fixed the issue, I had a type in the fontname. As it's called "Bebas Neue" not "BabasNeue"
  • 1

iOS Development / Swift


This forum is for questions, comments, and general discussion about iOS Development and Swift.

Bucky Roberts Administrator