dhanjit
dhanjit

Reputation: 59

How to set font style for table view cell (navigation based app) in iphone

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

Upvotes: 6

Views: 18705

Answers (5)

james
james

Reputation: 646

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];

Upvotes: 0

Gerald Spreer
Gerald Spreer

Reputation: 413

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/

Upvotes: 0

TheTiger
TheTiger

Reputation: 13354

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!!

Upvotes: 7

DLende
DLende

Reputation: 5242

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]

Upvotes: 15

Michael Dautermann
Michael Dautermann

Reputation: 89509

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).

Upvotes: 2

Related Questions