AMAN77 AMAN77 - 2 months ago 25
iOS Question

How do I change the font color in a tableview cell to a variable UIColor?

I am adding the color here but it is not reflecting in the cell.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
cell.textLabel.font =[UIFont systemFontOfSize:14];
//cell.textLabel.textColor = theFontColor;//this does not work
//cell.textLabel.textColor = [UIColor whiteColor];//this works
// Configure the cell.

[self configureCell:cell atIndexPath:indexPath];

return cell;


The comfigureCell was overriding the color. Sorry was a real noob error.


Have you defined somewhere theFontColor as a UIColor

You should do for example:

     UIColor *theFontColor = [UIColor colorWithRed:64.0f/255.0f green:58.0f/255.0f blue:43.0f/255.0f alpha:1.0f];

...and then use it