1
사용자 지정 셀이있는 테이블을 만들었습니다. 모든 셀은 텍스트 필드입니다. 랜덤 셀을 클릭하면 다음 사진 링크와 같이 다른 초점이 맞춰지지 않은 셀에 그림자 레이어 (투명 bockground)가 나타납니다.표 셀을 클릭 할 때 그림자 배경
http://i47.tinypic.com/nwd45e.png
사용자 지정 셀이있는 테이블을 만들었습니다. 모든 셀은 텍스트 필드입니다. 랜덤 셀을 클릭하면 다음 사진 링크와 같이 다른 초점이 맞춰지지 않은 셀에 그림자 레이어 (투명 bockground)가 나타납니다.표 셀을 클릭 할 때 그림자 배경
http://i47.tinypic.com/nwd45e.png
당신이합니다 (있는 tableView 색상 당신이 원하는 것을 할 수 있도록 기본적으로 분명하다) 기본 색상을 가지고 스토리 보드/XIB에 tableViewCell의 배경을 설정 한 경우에, 당신은 같은 뭔가를 할 수 수행원.
// assume that the background color for the tableView in the storyboard is lightOrange,
// as seen in http://i47.tinypic.com/nwd45e.png
- (UITableViewCell*)tableView:(UITableView*)tableView
cellForRowAtIndexPath:(NSIndexPath*)indexPath
{
... the normal code for getting your cell, probably involving DequeueReusableCell ...
// yes, the following gets called for every row even when selection doesn't change,
// but it is a very small hit. could be replaced by overriding reloadData for the
// tableView, but that isn't always desirable.
if (tableView.indexPathForSelectedRow)
tableView.backgroundColor = [UIColor grayColor];
else
tableView.backgroundColor = [UIColor lightOrangeColor];
return cell;
}
- (void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath
{
... whatever else you would do for a selected row, perhaps a segue or something ...
... (and if part of this is to de-select a row that is already selected, take that ...
... into account as a conditional for the following line of code.
tableView.backgroundColor = [UIColor grayColor];
}
그림에서 효과를 내기 위해 배경색과 텍스트의 색을 변경해야 할 수도 있습니다. – KDaker
@KDaker : 동의 함. 나는 이것에 대한 대답을 간단히 편집하는 것을 고려한 다음, 텍스트를 변경하는 방법이 셀의 유형 (제목, 제목 + 설명, 사용자 정의)에 따라 달라질 것임을 깨달았다. –