2012-05-15 4 views
0

UITableViewCell의 initWithStyle 메서드에서 UILabel 텍스트 색을 변경하려고합니다. 하지만 색상이 바뀌지는 않습니다. 그러나 cellForRowAtIndexPath 메서드에서 색상을 변경하면 색상이 변경됩니다. 왜? 난 당신이 다음과 같이 사용하고 생각 - (UITableViewCell*)tableView:(UITableView *)tableView 방법에 tableViewCell를 만들기위한사용자 지정 셀 레이블 텍스트 색

: 당신이 당신의 라벨을 사용하는 방법은 단지 텍스트 색상 속성을 설정해야합니다 따라

+3

cellForRowAtIndexPath에 작성한 코드를 넣으시겠습니까? –

+0

그리고 initwithStyle의 코드를 입력하십시오. 스토리 보드 및 프로토 타입 셀을 사용하고 있는지 여부도 알려주십시오. – jrturton

답변

0

cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"]; 

는 가능성이있을 수 있음을 귀하의 스타일은 UITableViewCellStyleDefault 또는 UITableViewCellStyleValue1 or UITableViewCellStyleValue2 or UITableViewCellStyleSubtitle` 중 하나입니다.

어떤 스타일의 당신이 사용하는 것보다 자신의 레이블을 추가하는 경우 사용중인 현재 : textLabel 또는 UITableViewCell 객체의 detailTextLabel입니다 기본 레이블을 사용하여

UILabel *lbl = [[UILabel alloc] initWithFrame:CGRectMake(10,10,100,25)]; 
lbl.text = @"your Text"; 
[lbl setTextColor:[UIColor greenColor]]; 

을하고 당신이 당신의 자신의 레이블을 추가하지 않는 경우 :

UILabel *lbl = [[UILabel alloc] initWithFrame:CGRectMake(10,10,100,25)]; 
lbl.text = @"your Text"; 
[lbl setTextColor:[UIColor greenColor]]; 
: 당신처럼 서브 뷰에서 라벨을 추가하는 경우
[cell.textLabel setTextColor:[UIColor greenColor]]; 
[cell.detailTextLabel setTextColor:[UIColor greenColor]]; 

greenColor을 원하는 색상으로 바꿀 수 있습니다. 호프가 도움이 되길 바랍니다.

관련 문제