Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Easy way to add custom fonts to iOS apps!

Hey guys! After some research and experimentation I have found a really simple way to incorporate custom fonts into your iOS applications! I was looking around for a way to spruce up my Crystal Ball app with text that matched the app's title and "Shake to Predict" text. The font was one called Baldur.ttf and I had to download it online.

The first step is to create a 'Resources' folder if you don't already have one on the same level as Frameworks, Products, CrystalBall etc. Drag and drop your font into this folder. It will prompt you. Make sure your app is targeted and it is making a copy to the Resources folder. Next, open your ...-info.plist file and right or control-click to create a new key. Name this key 'Fonts provided by application' and it should auto-complete. Make sure it's an array and hit enter. Now under item 0's value column, click and type in the name of your font, including the extension. In my case that was Baldur.ttf. Finally, when you have some text you want to format, for example our prediction label, you use: self.predictionLabel.font = [UIFont fontWithName:@"YourFontName" size:12.0]; Easy as that! Just be sure that you use your actual font name which can be found by opening your font with Fontbook and looking at the top of the window. Mine was just Baldur.

2 Answers

Nice and useful post :)

Oliver Montes
Oliver Montes
3,338 Points

thx for sharing this :)