The docs say:
+ (UIFont *)fontWithName:(NSString *)fontName size:(CGFloat)fontSize
The fully specified name of the font. This name incorporates both the font family name and the specific style information for the font.
The examples I find only specify a font name. But I want to specify other attributes as well such as medium font weight etc. How is this encoded into the name?
In CSS, we use the font-family property to specify the font of a text. Note: If the font name is more than one word, it must be in quotation marks, like: "Times New Roman".
To change font type purely with HTML, use the CSS font-family property. Set it to the value you want and place it inside a style attribute. Then add this style attribute to an HTML element, like a paragraph, heading, button, or span tag.
There are two types of font family names: family-name - The name of a font-family, like "times", "courier", "arial", etc. generic-family - The name of a generic-family, like "serif", "sans-serif", "cursive", "fantasy", "monospace".
In CSS (and in typography in general) there are five basic types, or families, of fonts: serif, sans serif, cursive, fantasy, and monospace.
See this answer for naming scheme. Full font list (with names) can be found here.
Example:
[UIFont fontWithName:@"HelveticaNeue-Bold" size:15.0];
Update
iOS 8.2 added this method for fetching system fonts of different weights.
Example:
[UIFont systemFontOfSize:15.0 weight:UIFontWeightBold];
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