컬렉션 리스트뷰를 사용하다가 cell의 배경색을 바꾸려고 했지만 backgroundColor를 바꾸는 것으로는 바뀌지 않았다.
cell.backgroundColor = .backgroundColor
해결방법
backgroundView를 배경색 view로 넣어주었더니 변경되었다.
let background: UIView = {
let view = UIView()
view.backgroundColor = .backgroundColor
return view
}()
cell.backgroundView = background
비슷한 방법으로 cell이 클릭된 것처럼 보이지 않게 하려면 selectedBackgroundView를 바꿔준다.
let selectedBackground: UIView = {
let view = UIView()
view.backgroundColor = .clear
return view
}()
cell.selectedBackgroundView = selectedBackground
'iOS > STUDY' 카테고리의 다른 글
[iOS] UIToolbar 이슈 (UIToolbarContentView, UIButtonBarStackView) (0) | 2022.04.29 |
---|---|
[iOS] 레이아웃이 깨졌을 때 콘솔창 버그 (0) | 2022.04.26 |
[iOS] reloadItems, reconfigureItems 차이점 (1) | 2022.04.23 |
[iOS] CAGradientLayer (그라데이션 배경) (1) | 2022.04.05 |
[iOS] @discardableResult (0) | 2022.04.05 |