Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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 :)