Dealing with the UIFont class

Working with UIFont

The UIFont class in the iPhone SDK allows you to apply fonts to all text in your app and provides access to all fonts and sizes available on the iPhone as standard. Since it is the only way to describe a font within the SDK it is a pretty useful class and worth knowing well so here are a few good samples.

Samples

The first sample creates a font with by name with a specific sizing (specified by a float)

//create the font 
UIFont *myFont = [UIFont fontWithName:@"Courier" size:14.0];

//change the font size to 10
[myFont fontWithSize:10.0];

It is also possible to forgo naming your font, but to use the system default font with calls to

/*
+ systemFontOfSize:
+ boldSystemFontOfSize:
+ italicSystemFontOfSize:
*/

//using these calls

//creating a non-bold system font
UIFont *myFont = [UIFont systemFontOfSize:14.0];

//creating a bold system font
UIFont *myBoldFont = [UIFont boldSystemFontOfSize:14.0];

//creating an italic system font
UIFont *myItalicFont = [UIFont italicSystemFontOfSize:14.0];

All available UIFont fonts

The following picture shows all the fonts available via the UIFont class in their various forms (italic/bold)

 

UIFont samples

UIFont samples

  • Reddit
  • Digg
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • NewsVine
  • TwitThis
  • LinkedIn
  • Technorati
  • Netvibes
  • StumbleUpon
  • MySpace
  • SphereIt

Similar Posts

    None Found

Leave a Reply