UICollectionView showing scroll indicator for every section (header zIndex broken)

Viewed 4506

When scrolling through my UICollectionView it's showing more than one scroll indicator. I've noticed there is a one for every section in the collection. See screenshot displaying three at the same time:

enter image description here

Anyone experienced same issue? I am using Xcode 9 beta 3. My collectionview setup is quite common:

private let formCollectionView: UICollectionView = {
        let collectionViewLayout = UICollectionViewFlowLayout()
        collectionViewLayout.minimumLineSpacing = 0
        collectionViewLayout.minimumInteritemSpacing = 0
        let collectionView = UICollectionView(frame: .zero, collectionViewLayout: collectionViewLayout)
        collectionView.translatesAutoresizingMaskIntoConstraints = false
        collectionView.backgroundColor = UIColor.clear
        return collectionView
}()

Edit 10/16/2017

Even Twitter seems having this issue:

enter image description here

4 Answers

That are not multiple scroll indicators. The z index of the header views is higher than that of the scroll indicator view.

Edit: found something more interesting, if you run the view debugger the scroll indicator is positioned above the headers... something weird is going on.

There is a simple method to fix this problem. In your section header view Class, you can override method layoutSubviews, and write:

- (void)layoutSubviews {
    [super layoutSubviews];
    self.layer.zPosition = 0;
}

Because, before iOS11, the section view's layer zPosition value is default 0, but in iOS11, this default value is 1.

Related