我在此处添加颜色,但它没有反射(reflect)在单元格中。
- (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;
}
编辑
configureCell 覆盖了颜色。抱歉,这是一个真正的菜鸟错误。
最佳答案
你是否在某处将 theFontColor 定义为 UIColor
你应该这样做:
UIColor *theFontColor = [UIColor colorWithRed:64.0f/255.0f green:58.0f/255.0f blue:43.0f/255.0f alpha:1.0f];
...然后使用它
关于ios - 如何将表格 View 单元格中的字体颜色更改为变量 UIColor?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8241310/