How can I change the font of a tag programmatically?

Possible duplicate:
UILabel configuration - Font through code - generates an error - iPhone

I want to know if there is a way to set the font of the label programmatically, since I need to change the font in my application when the condition is set to true. How can I do this using various Apple fonts?

+5
source share
4 answers

Make a list of available fonts:

for( NSString *strFamilyName in [UIFont familyNames] ) {
  for( NSString *strFontName in [UIFont fontNamesForFamilyName:strFamilyName] ) {
    NSLog(@"%@", strFontName);
  }
}

Now set Font likethis is:

 [yourLabel setFont:[UIFont fontWithName:@"your font name here" size:fontsizehere]];

EDIT :

For example, for example:

 [yourLabel setFont:[UIFont fontWithName:@"Arial" size:15]];
+12
source

This code is used here.

[labelname setFont:[UIFont fontWithName:@"American Typewriter" size:18]];
+1
source

UIFont *font = [UIFont fontWithName:@"MyFont" size:20];
    [label setFont:font];
+1

//

label.font = [UIFont fontWithName:@"Calibri" size:15];

//

label.textColor = [UIColor redColor]; 

// colr, RGB

label.textColor = [UIColor colorWithRed:180.0/255.0 green:6.0/255.0 blue:47.0/255.0 alpha:1.0];
+1
source

All Articles