Reputation: 8168
I want to change Font type and size in UITableView
. For example, how would I set it to Tahoma?
Upvotes: 23
Views: 21627
Reputation: 523174
cell.textLabel.font = [UIFont fontWithName:@"ArialMT" size:144];
where cell
is a UITableViewCell
you would return in -tableView:cellForRowAtIndexPath:
.
Tahoma is not shipped with iOS by default, nor can you legally copy it without a proper license. But you could provide a custom free font if you don't like Arial, see How to include and use new fonts in iPhone SDK?.
Upvotes: 40
Reputation: 5782
To add to KennyTM's answer:
You can use - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
delegate method of UITableView
to configure your UITableViewCell
like this:
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
cell.textLabel.textColor=[UIColor whiteColor];
cell.detailTextLabel.font=[UIFont fontWithName:@"Helvetica" size:16.0];
cell.detailTextLabel.textColor=[UIColor whiteColor];
}
Apple document reads:
A table view sends this message to its delegate just before it uses cell to draw a row, thereby permitting the delegate to customize the cell object before it is displayed. This method gives the delegate a chance to override state-based properties set earlier by the table view, such as selection and background color. After the delegate returns, the table view sets only the alpha and frame properties, and then only when animating rows as they slide in or out.
Upvotes: 7