User Tools

Site Tools


objective-c:examples:fonts

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

objective-c:examples:fonts [2012/12/20 12:24] (current)
Line 1: Line 1:
  
 +====== Custom Fonts ======
 +
 +Using a custom font in Cocoa touch\\
 +
 +There are a lot of fonts provided by iOS. This example will use "Heiti SC".
 +
 +
 +Importing a font not provided by iOS
 + 
 +Sample Font: Lobster.otf
 +
 +1. Copy the font into your project.\\
 +2. Go to project info.plist and add the key: "fonts provided by application". It should be kind of type array.\\
 +3. Insert the font as item into the array. The item font-name must be the name of your font-file (here: Lobster.otf).
 +
 +
 +<code objc>
 +- (void)viewDidLoad
 +{
 +    [super viewDidLoad];
 +    // Do any additional setup after loading the view from its nib.
 +    
 +    // ** Label with Font Heiti SC (is provided by iOS) **
 +    UILabel *iOSFontLbl = [[UILabel alloc]initWithFrame:CGRectMake(40.0f, 20.f, 230.0f, 42.0f)];
 +    iOSFontLbl.font = [UIFont fontWithName:@"Heiti SC" size:14.0f];
 +    iOSFontLbl.text = @"code-reference.com - Heiti SC";
 +    
 +    [self.view addSubview:iOSFontLbl];
 +    
 +    // ** Label with Font Lobster (is not provided by iOS) **
 +    UILabel *customFontlabel = [[UILabel alloc]initWithFrame:CGRectMake(40.0f, 80.f, 230.0f, 42.0f)];
 +    customFontlabel.font = [UIFont fontWithName:@"Lobster" size:8.0f];
 +    customFontlabel.text = @"code-reference.com - Lobster";
 +    
 +    [self.view addSubview:customFontlabel];
 +}
 +</code>
advertising
objective-c/examples/fonts.txt · Last modified: 2012/12/20 12:24 (external edit)

Impressum Datenschutz