[Swift] 특정 IndexPath에 있는 collectionViewCell을 StickyHeader로 만들기

Make UICollectioViewCell StickyHeader using UICollectionViewFlowLayout

요구 사항

stickyIndexPath를 IndexPath(row: 4, section: 0)로 설정 -> 분홍색 cell이 sticky Header 처럼 작동

시작하기 with Starter Project

Customize UICollectionViewFlowLayout

in ViewController.swift

prepare()

collectionViewContentSize

layoutAttributesForElements(in:)

let columnLayout = CustomCollectionViewFlowLayout(stickyIndexPath: stickyIndexPath)self.collectionView.collectionViewLayout = columnLayout

CustomCollectionViewFlowLayout.swift

마무리

전체 프로젝트

참고

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store