Skip to content

Commit

Permalink
fix : show custom headerView in collectionView (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
JacksonPk committed Apr 21, 2021
1 parent ec2592b commit 49b453b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,8 @@ class CollectionViewDataSource: NSObject, UICollectionViewDataSource {
}

func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
let headerView = collectionView.dequeueReusableSupplementaryView(ofKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: SectionHeaderView.identifier, for: indexPath)

// headerView.frame.size.height = 32
let headerView = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: SectionHeaderView.identifier, for: indexPath)

return headerView
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize {
let width: CGFloat = collectionView.frame.width
let height: CGFloat = 32
return CGSize(width: width, height: height)
}



// func collectionView(collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, atIndexPath indexPath: NSIndexPath) -> UICollectionReusableView {
//
// let headerView = collectionView.dequeueReusableSupplementaryViewOfKind(UICollectionElementKindSectionHeader, withReuseIdentifier: "headerView", forIndexPath: indexPath)
//
// headerView.frame.size.height = 100
//
// return headerView
// }
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,11 @@ class CollectionViewDelegate: NSObject, UICollectionViewDelegate, UICollectionVi
}
}

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize {
let width: CGFloat = collectionView.frame.width
let height: CGFloat = 32
return CGSize(width: width, height: height)
}


}
1 change: 1 addition & 0 deletions iOS/BanchanCode/BanchanCode/Views/SectionHeaderView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ class SectionHeaderView: UICollectionReusableView {
sectionTitleLabel.text = "모두가 좋아하는 든든한 메인 요리"
}


}

0 comments on commit 49b453b

Please sign in to comment.