2014-10-02 2 views
1

배열이 UIColors로 가득 찼습니다. 파이 차트에서 색상을 복제하는 키로 사용하려면 셀 배경색으로 설정하고 싶습니다.UIColor 배열에서 셀 배경 설정

self.sliceColors =[NSArray arrayWithObjects: 
         [UIColor colorWithRed:246/255.0 green:155/255.0 blue:0/255.0 alpha:1], 
         [UIColor colorWithRed:129/255.0 green:195/255.0 blue:29/255.0 alpha:1], 
         [UIColor colorWithRed:62/255.0 green:173/255.0 blue:219/255.0 alpha:1], 
         [UIColor colorWithRed:229/255.0 green:66/255.0 blue:115/255.0 alpha:1], 
         [UIColor colorWithRed:148/255.0 green:141/255.0 blue:139/255.0 alpha:1],nil]; 

그게 모든 미세 : 여기

이 배열된다. 나는 셀을 색칠하는 구문을 작성하려고합니다. 둘러 보니 다음과 같이 나타났습니다.

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath 
{ 

} 

하지만 배열의 색상으로 채우는 방법을 모릅니다. 내가 시도한 모든 것은 구문 오류를 일으켰다.

+0

는 당신이 실제로 같이 하시겠습니까? 각 셀에 그 색상 중 하나를 갖고 싶습니까? 하나의 셀에 모든 색을 나타내시겠습니까? 어떻게 그들을 표시하고 싶습니까? – dfmuir

답변

3

잠재적 인 솔루션 :

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    cell.backgroundColor = self.sliceColors[indexPath.row % self.sliceColors.count]; 
} 
+0

부적을 부탁드립니다. 감사합니다. – spogebob92