2012-08-27 5 views

답변

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

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"]; 
    [self configureCell:cell atIndexPath:indexPath]; 


    for (int x = 0; x < [[self.fetchedResultsController sections] count]; x++) { 

     id <NSFetchedResultsSectionInfo> sectionInfo = [[self.fetchedResultsController sections] objectAtIndex:x]; 

     int d = [sectionInfo numberOfObjects]; 

     if(indexPath.section == x){ 

      if (indexPath.row == 0 || indexPath.row == d-1) { 

       cell.backgroundColor = [UIColor blackColor]; 

      }else{ 

       cell.backgroundColor = [UIColor whiteColor]; 

      } 

     } 
    } 

    return cell; 
} 
2

은 같은 것을 할 tableView:cellForRowAtIndexPath: : 내 대답에

if (indexPath.row == 0 ||  
    indexPath.row == [tableView numberOfRowsInSection:indexPath.section] - 1) { 
    cell.backgroundColor = [UIColor redColor]; // or anything you want. 
} 
+0

모습을. 첫 번째 또는 마지막 셀 또는 중간 셀의 색상을 각각 개별적으로 변경할 수 있습니다. – NamshanNet

+0

Yaser, 질문을 게시하고 직접 답장을 원하면 ** 자신의 질문에 답하십시오 ** 옵션을 선택하십시오. 그러면 답을 게시 할 때까지 질문이 나타나지 않습니다. http://blog.stackoverflow.com/2011/07/its-ok-to-ask-and-answer-your-own-questions/ – DrummerB

관련 문제