Possible Duplicate:
Setting UILabel - Font through code - generates error - iPhone
I want to know is there any way to set the font of a label programmatically as I need to change the font in my app when a condition is set true. How can I do so using Apple's variety of fonts?
To change or set a font style for certain text, the fontFamily CSS property needs to be changed. The fontFamily property sets or returns a list of font-family names for text in an element. To change the font style by option dropdown: The font values can be passed in option tags using option value.
A form with a label and a button 'Options'. By clicking the button a new form opens with 2 radio buttons 'Font1' and 'Font2', and two buttons 'Apply' and 'Cancel'. Upon selecting one of the radio buttons and clicking 'Apply' will make the label on the first form change the font face.
To change the font or the size of a UILabel in a Storyboard or . XIB file, open it in the interface builder. Select the label and then open up the Attribute Inspector (CMD + Option + 5). Select the button on the font box and then you can change your text size or font.
Make yourself a list of available fonts:
for( NSString *strFamilyName in [UIFont familyNames] ) {
for( NSString *strFontName in [UIFont fontNamesForFamilyName:strFamilyName] ) {
NSLog(@"%@", strFontName);
}
}
Now set Font
like
this:
[yourLabel setFont:[UIFont fontWithName:@"your font name here" size:fontsizehere]];
EDIT :
For example like this:
[yourLabel setFont:[UIFont fontWithName:@"Arial" size:15]];
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