Using Xcode 7 and swift 2
I have assigned a string for each font in Info.plist -> Fonts provided by application -> Array
How do i loop through all these fonts and assign in for loop
I tried : Output was nil
var familyList = NSBundle.mainBundle().objectForInfoDictionaryKey("Fonts provided by application") as [String]
I came across below code which gives me list of all family names, which i dont need.
I Need same to loop only with fonts i have added.
for family: AnyObject in UIFont.familyNames() {
println("Font Family: \(family)")
for font: AnyObject in UIFont.fontNamesForFamilyName(family as NSString) {
println("Font Name: \(font)")
}
}
To retrieve the info in the Info.plist, you can use objectForInfoDictionaryKey() with UIAppFonts for the key.
I don't speak Swift, and I don't know if the code compile, but you should be able to get the idea.
let fonts = NSBundle.mainBundle.objectForInfoDictionaryKey(UIAppFonts) as NSArray
That should give you the array of the fonts. It's up to you then to construct the UIFont objects.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With