For some reason my scrollbar always appears underneath the collection view section header. Any help is greatly appreciated!
相关问题
- “Zero out” sensitive String data in Swift
- SwiftUI: UIImage (QRCode) does not load after call
- Get the NSRange for the visible text after scroll
- UIPanGestureRecognizer is not working in iOS 13
- What does a Firebase observer actually do?
相关文章
- Using if let syntax in switch statement
- Enum with associated value conforming to CaseItera
- Swift - hide pickerView after value selected
- Is there a Github markdown language identifier for
- How can I vertically align my status bar item text
- Adding TapGestureRecognizer to UILabel in Swift
- Attempt to present UIAlertController on View Contr
- Swift - Snapshotting a view that has not been rend
Here is my alternative which seems to work better on iOS12 when subclassing
UICollectionReusableView
.With a long-scrolling, async-loading collection, this alternative may offer slightly better performance.
I found a workaround. This issue is that the
zPosition
of the header view is being set by the collection view incorrectly. To fix this, we will always ensure that thezPosition
is our desired value.Create a
CALayer
subclass which prevents thezPosition
from being anything other than 0.Then set the layer class of your collection view header to this new subclass.
This is an iOS 11 bug, as this issue does not occur in iOS 10. Hopefully this works well enough until the bug is fixed.
Same concept, but here is a simpler workaround that doesn't require your
UICollectionReusableView
instances to use a subclass.Conform to
UICollectionViewDelegate
(if you don't already) and implement willDisplaySupplementaryView protocol method like so:func collectionView(_ collectionView: UICollectionView, willDisplaySupplementaryView view: UICollectionReusableView, forElementKind elementKind: String, at indexPath: IndexPath) { view.layer.zPosition = 0.0 }
Tested in iOS 11.2.1.