Skip to content

Instantly share code, notes, and snippets.

View heoblitz's full-sized avatar
👨‍🚒

Won Heo (Woody) heoblitz

👨‍🚒
View GitHub Profile
@heoblitz
heoblitz / custom_layout_4.swift
Created December 19, 2020 06:09
custom_layout_4.swift
class PinterestLayout: UICollectionViewFlowLayout {
// ...
// 3. 모든 셀과 보충 뷰의 레이아웃 정보를 리턴합니다. 화면 표시 영역 기반(Rect)의 요청이 들어올 때 사용합니다.
override func layoutAttributesForElements(in rect: CGRect)
-> [UICollectionViewLayoutAttributes]? {
var visibleLayoutAttributes: [UICollectionViewLayoutAttributes] = []
for attributes in cache {
if attributes.frame.intersects(rect) { // 셀 frame 과 요청 Rect 가 교차한다면, 리턴 값에 추가합니다.
visibleLayoutAttributes.append(attributes)