简体   繁体   中英

Storing names of fonts in an NSMutableArray

How can I store the names of all the fonts available on iOS in an NSMutableArray? This is for later usage and for displaying them on a table view

all font names installed:

id families = [UIFont familyNames];
id fonts = [NSMutableArray array];
for(id fam in families) {
    [fonts addObjectsFromArray:[UIFont fontNamesForFamilyName:fam]]; 
}

[UIFont familyNames] is what you are looking for. If you also want to know what kind of fonts are available in a given family, you can use [UIFont fontNamesForFamilyName] .

They both return an inmutable array, if you really need a mutable one (for whatever reason), you can simply make a mutable copy of it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM