How to show scrollbar over header or footer view
Overview
After revisiting my old codes, I found some useful code that helped a bug. Although this bug is solved over iOS 13, if your project deployment target is iOS 12 or under, this code might be useful.
Only from iOS 12 and under produces this bug. From iOS 13 and above, this bug doesn’t occur.
Scrollbar goes under the header or footer view
As the below image shows, the scrollbar is under the header view. It was a strange bug, and does not look good. But adding the below code helped the bug. It looks like the scrollbar layer’s zPosition was lower than the header view layer’s zPosition.
1
2
3
func collectionView(_ collectionView: UICollectionView, willDisplaySupplementaryView view: UICollectionReusableView, forElementKind elementKind: String, at indexPath: IndexPath) {
view.layer.zPosition = 0
}
Reference:
StackOverflow
이 기사는 저작권자의 CC BY 4.0 라이센스를 따릅니다.