Cell

컬렉션 뷰의 콘텐츠를 표시

Supplementary View

섹션에 대한 정보를 표시

Decoration View

컬렌션 뷰에 대한 배경을 꾸밀 때 사용

UICollectionVIewLayout

시각적 효과를 담당한다

UICollectionViewFlowLayout

셀을 그리는 방식을 정의함

  1. Flow 레이아웃 객체를 작성하고 컬렉션 뷰에 이를 할당함.
  2. 셀의 width, height를 정한다. ⇒ 디폴트 값이 0이기 때문에 지정하지 않을시 화면에 표시되지 않음
  3. 필요한 경우 셀들 간의 좌우 최소 간격, 위아래 최소 간격 설정
  4. 섹션에 header 와 footer가 있다면 이것들의 크기를 지정한다.
  5. 레이아웃의 스크롤 방향을 설정한다.

UICollectionViewDataSource - 주요 메서드

public protocol UICollectionViewDataSource:NSObejectProtocol{
	//지정된 섹션에 표시할 셀의 개수를 묻는 
	func collectionView(_ collectionView: UICollectionView,
										 numberOfItemsInSection section:Int)->Int
	//지정된 위치에 표시할 셀을 정의
	func collectionView(_ collectionView: UICollectionVIew,
										 cellForItemAt indexPath: IndexPath)-> UICollctionViewCell
	//섹션의 개수를 묻는
	optional func numberOfSection(in collectionView:UICollectionView)->Int

}

CollectionView와 관련된 핵심 객체들의 관계

스크린샷 2022-02-21 오후 1.13.22.png