This is a Swift 2.2 version of previous ObjC tutorial. Sometimes it's very useful to check, which UIFonts are already available, and which should be imported. In this little tutorial, I will show, how can you import your own custom Font, and how can you check the available UIFonts and Families in your Xcode Project. IOS 9.3 Xcode 7.3 Swift 2.2
Create a SingleView Xcode Project. In your ViewController.swift file put this code to print out your all available UIFonts:
Now run your project and check the logs. My result:
If you have one, that's ok, if you need one, download here a new Font: www.google.com/fonts
Find a Font, which isn't in your Log list! :) I will import here Lato.
2.1 Download and Add to your Xcode Project
Download it with click on the right small arrow, and choose .zip. After that, drag and drop in Xcode.
2.2 Now you need to add your new File names at Info.plist file.
Click on your Info.plist file, and at "Information Property List" click the plus button, and search (start to type) for "Fonts provided by application".
Add new File names as new Items. (Very important to use the exact name of the Font file!)
2.3. Check it!
And Check your Target at Build Phases under the "Copy Bundle Resources", that your all imported files are there!
If everything works fine, you can check your available UIFonts again. Run your App. And in Log with cmd+f search for your new Font Name. (First of all, trash your log ;)
Now you can see your new UIFont names. You must to use these names in your log, if you use it with this form for instance: "string.font = UIFont(name: "Lato-Black", size: 12)" Sometimes what you can see in log is different from your exact File name. Therefore you need to check it always after your import.
And of course, if you don't add your Font name to your Info.plist file, that will be mot available in your App. At me, I added just 4 type of this Font Family, and if I want to use "Lato-Italic", that will be not work, because I didn't add it to the Info.plist file.
Download the Xcode template from Github.
If you would like to be notified of my new solutions, please subscribe to my Newsletter or my youtube channel and/ or follow me on Facebook or Twitter! Check Footer section for these opportunities!