ios - 如何将表格 View 单元格中的字体颜色更改为变量 UIColor?

标签 ios objective-c uitableview fonts colors

我在此处添加颜色,但它没有反射(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/

相关文章:

ios - 用户在 iOS 中进行应用内购买并且没有付款数据时的流程

iOS:将观察者添加到 UIView 的 frame.origin.y?

ios - Collection View 顶部的奇怪间隙

android - Css 不适用于 Iphone

ios - Objective-C 标准化 iPhone 内置麦克风的 dB 电平

c++ - 以太网 IOKit Cocoa 上的网络驱动程序

java - Objective C 中的类对象

ios - 图像未显示在表格 View 中

ios - 为什么我的单元格在我的 UITableView 中显示为空白?

ios - 在 View Controller 之间传递对象