2014-03-19 2 views
0

UITableViewCell 텍스트 UIColour (의상 셀)을 변경하면 텍스트가 흰색으로 보이지 않게됩니다. UITableViewCell을 터치 할 때만 텍스트가 표시됩니다. 을 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 사이 여야합니다.

당신은 당신이 휴대 텍스트 색상을받지되는 각 매개 변수 뒤에 .0f (플로트)를 추가하고 있지 않습니다

[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

사용이 을보십시오.

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