0

I created a uitableview and in every cell there's a textLabel.

cell.textLabel.numberOfLines = 0;
cell.textLabel.text = [NSString stringWithFormat:@"Hello\n how are you?"];
UIFont *myFont = [ UIFont fontWithName: @"Novel" size: 6.0 ];
cell.textLabel.font  = myFont;

Can i set the font of "Hello" to 10 and the font of "how are you?" to 6?

Thank you!

iMash
  • 1,178
  • 1
  • 12
  • 33
Liatz
  • 4,997
  • 7
  • 28
  • 33
  • possible dup of - http://stackoverflow.com/questions/1417346/iphone-uilabel-containing-text-with-multiple-fonts-at-the-same-time – rishi Apr 27 '12 at 12:18

1 Answers1

-1

Do as per the following:

UILabel *flabel = [[UILabel alloc]init];
flabel.text = @"Hello";
flabel.font = [UIFont fontWithName:flabel.text size:10];
UILabel *slabel = [[UILabel alloc]init];
slabel.text = @"How are you?";
slabel.font = [UIFont fontWithName:slabel.text size:6];
cell.textLabel.text = [NSString stringWithFormat:@"%@\n%@",flabel.text,slabel.text];

I have created two different labels having different font size and set it to cell textlabel by concatenation of both strings. Hope this should work.

iMash
  • 1,178
  • 1
  • 12
  • 33
  • Thank you but It doesn't work... I think that : cell.textLabel.text = [NSString stringWithFormat:@"%@\n%@",flabel.text,slabel.text]; it sets only the text of the flabel and slabel and not the font and size prefrences – Liatz Apr 28 '12 at 07:43