Notice
														
												
											
												
												
													Recent Posts
													
											
												
												
													Recent Comments
													
											
												
												
													Link
													
											
									| 일 | 월 | 화 | 수 | 목 | 금 | 토 | 
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | |||
| 5 | 6 | 7 | 8 | 9 | 10 | 11 | 
| 12 | 13 | 14 | 15 | 16 | 17 | 18 | 
| 19 | 20 | 21 | 22 | 23 | 24 | 25 | 
| 26 | 27 | 28 | 29 | 30 | 31 | 
													Tags
													
											
												
												- port
- Unity
- mssql
- PER
- 맛집
- 리눅스
- Excel
- pandas
- 다이어트
- PyQt
- flutter
- javascript
- ASP
- PyQt5
- 유니티
- tensorflow
- GIT
- sqlite
- node.js
- swift
- 함수
- MS-SQL
- MySQL
- IOS
- ubuntu
- 날짜
- Linux
- urllib
- 라즈베리파이
- python
													Archives
													
											
											
											
											아미(아름다운미소)
[Swift] 스위프트 사이드메뉴 테이블셀 선택시, 셀의 배경색깔을 바꾸고 싶을때 본문
[Swift 3/4] Selecting and Deselecting UITableViewCells - Swift
//색상 변경을위해 cellForRowAt 메소드에 코딩
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) ->UITableViewCell{
   if self.selectedIndex == indexPath.row {
      cell.firstView.backgroundColor = UIColor.orange  // Highlight color
   }else {
      cell.firstView.backgroundColor = UIColor.clear // Original color
   }    
}
//배경 색상을 제거하려면 이전 행을 업데이트해야합니다.
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
{   
           previousIndex = selectedIndex          
          if(selectedIndex == indexPath.row) {
              selectedIndex = -1
          } else {
              selectedIndex = indexPath.row
          }
          let InPrev = IndexPath(row: previousIndex, section: indexPath.section)
          let indexPathArray: [Any] = [InPrev, indexPath]
          self.tableView.beginUpdates()
          self.tableView.reloadRows(at:indexPathArray,with: UITableViewRowAnimation.automatic)
          self.tableView.endUpdates()
} 
'랭귀지 > SWIFT' 카테고리의 다른 글
| [iOS Swift]UITableView didSelectRowAt TableView 행 선택 해제하기 (0) | 2018.05.13 | 
|---|---|
| Xcode에서 UINavigationController를 사용할 때 UIStatusBar의 배경색을 변경하는 방법 (0) | 2018.05.12 | 
| [Swift] 셀 선택시, 셀의 배경색깔을 바꾸고 싶을때 (0) | 2018.05.06 | 
| Swift 3.0 SWRevealViewController 전면 뷰 컨트롤러의 뷰를 비활성화 (0) | 2018.04.27 | 
| XCode9: iPhone is busy 메시지 관련 (0) | 2018.04.09 | 
			  Comments