6

Please help me. How to set different font styles (stylish sentences in table view cell) programmatically for table view cell???

dhanjit
  • 59
  • 1
  • 1
  • 2

5 Answers5

15

You can follow this guide for adding custom fonts on your app.

Adding custom font on iphone

Then you can call this code to set the font and font size

cell.textLabel.font = [UIFont fontWithName:@"custom" size:12.0f]
Community
  • 1
  • 1
DLende
  • 5,162
  • 1
  • 17
  • 25
7

You can set it with the help of UIFont see this code -

cell.textLabel.textColor=[UIColor whiteColor];
cell.textLabel.font=[UIFont fontWithName:@"Arial Rounded MT Bold" size:15.0];
cell.textLabel.numberOfLines=2;
cell.textLabel.lineBreakMode=UILineBreakModeMiddleTruncation;
cell.textLabel.backgroundColor=[UIColor clearColor];

here are many property of UITableViewCell who changes it look. You can also set a UILabel on UITableViewCell like this -

[cell.contentView addSubview:lblView];
//lblView is your UILabel you can set its UIFont whatever you want

Thank You!!

TheTiger
  • 13,264
  • 3
  • 57
  • 82
  • Thank you very much. Can you tell me some font styles like 'Custom', 'Arial'....or you can give me link of that where I can get a list and use whatever I need. Thanks a lot...... – dhanjit Jun 09 '12 at 06:04
  • go to you XIB file , take a UILabel object select it and go to its Attribute inspector (it is just right side of window), now see its Font property - click on T - choose custom - now you will see there are so many font name which objective supports... – TheTiger Jun 09 '12 at 06:16
  • @dhanjit - Please accept the answer if it helped you. You accepting rate is 0% ... Not good :) – TheTiger Oct 12 '12 at 10:55
2

If you are using a standard UITableViewCell, there's a "textLabel" property that you can access and set the font & size of (which you would do via UILabel's font property).

Michael Dautermann
  • 88,797
  • 17
  • 166
  • 215
0

Starting in iOS 4, its possible to use custom fonts. This post shows how to include them into your project and how to set them on your views: http://blog.beefyapps.com/2010/06/custom-fonts-in-ios-4/

Gerald Spreer
  • 413
  • 4
  • 11
0

you can add the font in the following way

    cell.textLabel.font = [UIFont fontWithName:@"Arail" size:12.0f];

OR

Give the font name as you want

      cell.textLabel.font = [UIFont fontWithName:@"yourFontNameHere" size:12.0f];
james
  • 646
  • 3
  • 9
  • 24