2014-03-19 33 views
0

试图更改UITableViewCell文本UIColour(服装单元格)将使文本变得白色和看不见,只有当触摸UITableViewCell时,我才能看到文本。 为什么将UIColour设置为UITableViewCell即不是blackColor将不起作用?更改TableView单元格颜色将不起作用

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

    static NSString *CellIdentifier = @"Cell"; 
    UITableViewCell *cell = 
    [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier 
              forIndexPath:indexPath];  
    if (!indexPath.row) { 
     NSDictionary *dic= [[GlobalData sharedGlobals].categories 
          objectAtIndex:indexPath.section]; 
     cell.textLabel.text = [dic objectForKey:@"title"]; // only top row showing 
     cell.textLabel.font = [UIFont fontWithName:@"Arial Rounded MT Bold" 
               size:22]; 
     cell.textLabel.textColor = [UIColor colorWithRed:177 
                green:218 
                blue:229 
                alpha:1]; 
     //cell.textLabel.backgroundColor = [UIColor colorWithRed:218 
                  green:241 
                  blue:245 
                  alpha:1]; 
    } else { 
     NSMutableArray *typesOfSection = 
     [[GlobalData sharedGlobals].typesByCategories 
      objectAtIndex:indexPath.section]; 
     NSDictionary *type = [typesOfSection objectAtIndex:indexPath.row-1]; 
     NSString *titleOfType = [type objectForKey:@"title"]; 
     cell.textLabel.text = titleOfType; 
     cell.textLabel.textColor = [UIColor colorWithRed:122 
                green:181 
                blue:196 
                alpha:1]; 
     cell.textLabel.font = [UIFont fontWithName:@"Arial Rounded MT Bold" 
               size:22]; 

     //cell.textLabel.text = @"check"; 
     cell.accessoryView = nil; 
     cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 
    } 

    return cell; 
} 

而且这样做时:

cell.textLabel.textColor = [UIColor redColor]; 

其工作..

回答

2

您的单元格的文本颜色基本上设置为白色。 RGB值应该在0.0到1.0之间。

试试这个

[UIColor colorWithRed:122.0/255.0 green:181.0/255.0 blue:196.0/255.0 alpha:1.0]; 
+0

谢谢,但这只是第一个被占用的单元格的颜色。有更多的细胞是空的 - 他们保持白色 – Curnelious

+0

你可能也想改变其他颜色。试试这个[UIColor colorWithRed:177.0/255.0 green:218.0/255.0 blue:229.0/255.0 alpha:1.0]; – singingAtom

1

使用此 您还没有添加.0f(浮动)通过你没有得到小区的文字颜色各参数后面。

[UIColor colorWithRed:122.0f/255.0f green:181.0f/255.0f blue:196 .0f/255.0f alpha:1.0f];