Last active
February 7, 2017 21:28
-
-
Save dornad/ce0720fbfeb181f4d697c13164e2a106 to your computer and use it in GitHub Desktop.
iOS Find Font Name [Swift 3]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/////////////////////////////////////////////////////// | |
//prints out available fonts. | |
// Adopted from http://codewithchris.com/common-mistakes-with-adding-custom-fonts-to-your-ios-app/#uifont | |
//WARNING!!! YOU MUST FOLLOW ALL THE STEPS TO GET THE FONT TO WORK. | |
//1. Include the font in the project | |
//2. Make sure that they’re included in the target | |
// Check build phases and check the target membership(s)) | |
//3. Double check that your fonts are included as Resources in your bundle. check copy resources in build phases section. make sure font is selected | |
//4. add a "Fonts provided by application" info.plist entry with each font's full filename (no typos!) | |
//5. find the name of the font with this code: | |
let familiesSorted = UIFont.familyNames.sorted() | |
for family: String in familiesSorted | |
{ | |
print("\(family)") | |
for names: String in UIFont.fontNames(forFamilyName: family) | |
{ | |
print("== \(names)") | |
} | |
} | |
//6. you can use code like this to access the font: | |
let label = UILabel() | |
label.font = UIFont(name: "QuicksandDash-Regular", size: 35) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment