반응형
UITableView의 셀 강조 색상 제거
uitableview 셀 선택의 기본 파란색을 제거하고 싶습니다. 나는 거기에 선택 색상을 원하지 않습니다. 사용자 지정 셀 클래스를 만들지 않았습니다. 셀 위에 레이블과 버튼을 추가하여 셀을 사용자 지정하고 있습니다. 나는 시도했다 :
cell.selectioncolor = [UIColor clearcolor];
그러나이 방법은 더 이상 사용되지 않는다고 말합니다.
cell.selectionStyle = UITableViewCellSelectionStyleNone;
에 스위프트 4 업데이트
cell.selectionStyle = UITableViewCell.SelectionStyle.none
또는
cell.selectionStyle = .none
Storyboard
또는 에서 선택XIB
// Swift 2.0
cell.selectionStyle = UITableViewCellSelectionStyle.None
스위프트 3.0
cell.selectionStyle = .none
목표 -C :
cell.selectionStyle = UITableViewCellSelectionStyleNone;
또는
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
스위프트 4 :
self.selectionStyle = UITableViewCellSelectionStyle.none;
스위프트 3 :
cell.selectionStyle = .none
스위프트 2 :
cell.selectionStyle = UITableViewCellSelectionStyle.None
Storyboard / Xib를 사용하여 변경하려면 "선택 스타일 효과"를 제거 할 셀을 선택하고 "없음"으로 정의하면됩니다. 마법처럼 작동합니다 : D
신속한 시도
cell?.selectionStyle = UITableViewCellSelectionStyle.None
TableView 선택 스타일을 .none
로 설정하면 내 앱에서 tableview의 응답 성과 성능에 영향을 미쳤습니다 ( didSelectRowAt indexPath
탭이 지연됨). 이 문제에 대한 내 해결책 awakeFromNib()
은 셀을 처음 만들 때 선택한 배경보기를 숨기는 것 입니다.
selectedBackgroundView?.isHidden = true
스위프트 5
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell")
cell.selectionStyle = .none
return cell
}
참고 URL : https://stackoverflow.com/questions/2787093/remove-the-cell-highlight-color-of-uitableview
반응형
'program story' 카테고리의 다른 글
IntelliJ에서 Scala 클래스를 만들 수 없습니다. (0) | 2020.08.29 |
---|---|
문자열에서 단어의 모든 첫 글자를 대문자로 바꾸는 방법은 무엇입니까? (0) | 2020.08.29 |
Scala : Scala 컬렉션에서 Traversable 특성과 Iterable 특성의 차이점은 무엇입니까? (0) | 2020.08.29 |
Vim의 각 줄 끝에 텍스트를 추가하는 방법은 무엇입니까? (0) | 2020.08.29 |
Print Statement를 사용하여 VARCHAR (MAX)를 인쇄하는 방법은 무엇입니까? (0) | 2020.08.29 |