2010-01-05 5 views
2

이미지를 배경으로 테이블을 만들려고합니다. 는이를 달성하기 위해, 나는 배경으로 시작 :이뿐만 아니라 tablecells에 나타나는 배경 이미지 결과UITableViewCellStyleSubtitle 레이블의 BackgroundColor?

self.view.backgroundColor = [UIColor groupTableViewBackgroundColor]; 

. 그건 내가 원하는 것이 아니기 때문에 셀의 backgroundColor를 설정하려고 시도했다.

cell.backgroundColor = [UIColor whiteColor]; 

이것은 전혀 효과가 없었다. 흠. 이상 하네. 이 거의 작동

UIView *backgroundView = [[UIView alloc] init]; 
backgroundView.backgroundColor = [UIColor whiteColor]; 
cell.backgroundView = backgroundView; 
[backgroundView release]; 

: 그래서 나는이 시도. 왼쪽의 유일한 문제는 textLabel &의 detailTextLabel에 여전히 배경이 표시된다는 것입니다. 해당 레이블의 backgroundColor를 흰색으로 설정해도 아무 것도 수행하지 않습니다.

어떻게 진행합니까? 어디서 잘못 나니? worldClock 앱처럼 tableView를 얻으려고합니다.

답변

10

는 테이블 뷰 셀의 배경 색상을 변경하려면, 당신은 그렇지 않으면 예를 들어, 영향을주지 않습니다 tableView:willDisplayCell:forRowAtIndexPath:보다는 tableView:cellForRowAtIndexPath: 에서 설정해야합니다 :

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { 
    cell.backgroundColor = [UIColor whiteColor]; 
} 
+0

감사합니다! 내가 필요한 것. –

+0

여전히 cellForRowAtIndexPath를 사용하는 이유를 충분히 이해하지 못했습니다 : 작동하지 않지만 내 문제를 해결했습니다. 감사! – radven

관련 문제