2013-05-22 2 views
0

아마도 중복 된 것으로 알고 있지만 셀을 선택하면 가장 좋고 가장 빠른 방법으로 파란색 강조 색을 변경할 수 있습니다. 저주의셀을 선택하면 파란색 강조 표시 색을 변경하는 방법

, 나는 이미 시도 (및 작동) 변화 셀이 (이 thread 등)을 선택 배경 색상을 구성하는 방법을하지만이 방법을 좋아하지 않아, 나는 정말로 선호 강조 표시 색상을 변경하십시오.

링크 또는 아이디어? 감사. 의 tableview의

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 

내부

+0

당신은 당신의 테이블 셀에 selectedBackgrounndView를 제공 할 수 있습니다. 이것이 가장 올바른 방법입니다. – Divyu

+0

U r 테이블보기를 만드는 방법 .. –

+0

파란색은'selectedBackgroundView' 속성에 상대적입니까? – Lucien

답변

6

가있는 UIImageView를 생성하고 세포의 같은 크기의 뷰를 만들 필요가 원하는 색상

if (cell == nil) { 
    UIImageView *bgView = [[UIImageView alloc]initWithFrame:cell.frame]; 
    bgView.backgroundColor = [UIColor greenColor]; 
    cell.selectedBackgroundView = bgView; 
} 
+2

@Lucien이 답변을 적용하십시오. 그것은 완벽합니다. – Warewolf

+0

예,이 [스레드] (http://stackoverflow.com/questions/1998775/uitableview-cell-selected-color)를 보지 못했으며 가장 적합한 대답은 적용된 것이 아닙니다. – Lucien

+0

윙윙 거리는 소리는 좋은 대답이지만 색조 효과를 유지하려면 어떻게해야합니까? : / – Lucien

0

첫째로는 배경 색상의 변경합니다. 해당 뷰에 배경색을 적용하십시오. 그런 다음 cellForRowAtIndexpath 대리자 메서드에서 셀의 선택된 배경으로보기를 설정합니다.

[cell setSelectedBackgroundView:yourView]; 
2

당신이 다음 셀의 속성 관리자에서 펜촉을 사용하여 테이블 뷰 셀을 작성하는 경우, 당신은 속성 "선택"을 볼 수 있습니다. 이것을 none으로 설정하십시오. UR 프로그래밍 방식으로 만드는 경우

, 그럼 당신은 원하는 색상과 세포의 selectedBackgroundView에 새로운 UIView의를 할당 할 수

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 



if (cell == nil) 
{ 
    cell.selectedBackgroundView.backgroundColor = [UIColor clearColor]; 

    UIImageView *bgView = [[UIImageView alloc]initWithFrame:cell.frame]; 
    bgView.backgroundColor = [UIColor redColor]; 

    cell.selectedBackgroundView = bgView; 
} 
0

로 셀을 설정합니다. 스위프트 3

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 
     let cell = tableView.dequeueReusableCell(withIdentifier: "departmentCell", for: indexPath) 

     let selectedView = UIView(frame: cell.frame) 
     selectedView.backgroundColor = ColorKit.cellSelectionColor 
     cell.selectedBackgroundView = selectedView 



     return cell 
    } 
0

이 방법이 라인을 쓰기

yourCell.selectionStyle = UITableViewCellEditingStyleNone; 
관련 문제