1
헤더에 레이블을 삽입하려고했지만 collectionView를 스크롤하면 다른 레이블이보기에 추가됩니다. 내가 어떻게 그걸 막을 수 있니? enter image description hereCollectionView 헤더의 레이블 문제
override func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "header", for: indexPath)
header.backgroundColor = .white
let label = UILabel(frame: header.bounds)
label.text = colorsArray[indexPath.section]
header.addSubview(label)
return header
}
정말 헤더를 사용해야하므로 그렇게 할 수 없습니다. –
하지만 UICollectionReusableView를 사용하여 헤더를 서브 클래스화할 수 있습니다. – Retterdesdialogs
아, 죄송합니다. 'cell.label.text = "something"'나를 혼란스럽게합니다. 맞습니다. 잘 작동합니다. 감사 –