Swift3 hitTest 활용하여 터치이벤트 확인하기 override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? { if self.circleView.frame.contains(point) { return super.hitTest(point, with: event) } return nil } 특정 뷰에 클릭이 이뤄졌는지 간단하게 확인할 수 있는 방법으로 위의 hitTest를 활용할 수 있습니다. 예제 코드에서는 어떠한 circleView를 탭했을 때에 작동하는 코드입니다. 2023. 1. 13. tableView의 header, footer view 색 변경하기 func tableView(_ tableView: UITableView, willDisplayHeaderView view: UIView, forSection section: Int) { if let header = view as? UITableViewHeaderFooterView { header.tintColor = ThemeManager.current.mainBackgroundColor header.textLabel?.textColor = ThemeManager.current.oppositeColor } } 테이블뷰를 나누는 섹션의 텍스트컬러와 배경컬러는 view as? UITableViewHeaderFooterView를 통해서 배경색은 header.tintColor, 텍스트컬러는 header.text.. 2023. 1. 5. filter 및 tableView section 활용하기 var contentCount = authHistories.filter({$0.regDtString.split(separator: ",").first! > authSection[indexPath.section]}).count cell.authTimeLabel.text = authHistories[indexPath.row + contentCount].regDtString 만약 여러가지 목록 중에서 해당 일자를 기준으로 그 이후에 일어난 사건에 대해 섹션으로 분리를 해야한다면, filter를 사용해서 일자값만 추출한 다음에 기준으로 잡을 해당 일자보다 더 앞선 컨텐츠만 count로 잡을 수 있습니다. 그런 다음 셀의 위치를 알려줄 때에는 indexPath.row에 contentCount를 더해서 전달해주면 .. 2022. 12. 30. 이전 1 다음