Can we use a font in iOS 6 if it's not include

2019-04-07 12:45发布

问题:

I would like to use the font "Avenir" which is included in iOS 6. Does that mean a device running iOS 5 won't be able to see the font? If so, is there a way to fallback on a different font if "Avenir" isn't available on their device?

回答1:

You can choose the font you want to be used in iOS < 6 and assign it if necessary. Define a macro like this:

#define SYSTEM_VERSION_LESS_THAN(v)      
       ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)

and then you can do in your code:

NSString *fontName = @"Avenir";

if SYSTEM_VERSION_LESS_THAN(6.0) { 
   fontName = @"ArialMT";
}

You can find a list of supported fonts here: http://iosfonts.com/