0

I have an array of labels

[labelsArray objectAtIndex:1] ????

I want to change label text style to bold and stressed. How can I do that?

Jonathan Sterling
  • 18,320
  • 12
  • 67
  • 79
cyclingIsBetter
  • 17,447
  • 50
  • 156
  • 241

2 Answers2

1

I do not understand what you mean by stressed but if you want to make it bold you can write:

UILabel *label = [labelArray objectAtIndex:1];
label.font = [UIFont fontWithName:@"Helvetica-Bold" size:18];

The size and font type is ofcourse up to you. Here are the list: http://www.prepressure.com/fonts/basics/ios-4-fonts

EDIT for comment: I have never done that, but after some searching I found this post at stackoverflow. You may try that, but there is no "built-in" function for this as far I know.

Underline text in UIlabel

Community
  • 1
  • 1
LuckyLuke
  • 47,771
  • 85
  • 270
  • 434
1

If there are different fonts in labels, that you don't know you can try this:

NSInteger i = 0;
for ( ... )
{
    UILabel *label = [labelArray objectAtIndex:i];
    UIFont *oldFont = label.font;
    NSString *fontName = [NSString stringWithFormat:@"%@-BoldItalic", oldFont.fontName];
    label.font = [UIFont fontWithName:fontName size:oldFont.pointSize];
}

Hope this'll help!

Jonathan Sterling
  • 18,320
  • 12
  • 67
  • 79
Zapko
  • 2,461
  • 25
  • 30