Introduction
Hello,
I have added a background view with a CAGradientLayer
, and my UICollectionViewCells
have a hole in them to see the background. So far, it all looks great:
The Problem
However, when I scroll to the very top (and also the very bottom) of the UICollectionView
, you can see the gradient background past the top of the first cell:
Question
What is something I can do to "mask" or "constrain" the gradient background to only being visible behind the cells, and not outside of the cell's frame/bounds?
Edit
This solves the top part, but I'm still not sure about the overflow on the bottom:
let header = UIView()
header.backgroundColor = UIColor.systemBackground
collectionView.addSubview(header)
header.snp.makeConstraints { (make) in
make.top.equalTo(self.view)
make.left.right.equalTo(self.view)
make.bottom.equalTo(self.collectionView.snp.top)
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…