我使用了以下代码。
CAGradientLayer* collectionRadient = [CAGradientLayer layer];
collectionRadient.bounds = self.collectionView.bounds;
collectionRadient.anchorPoint = CGPointZero;
collectionRadient.colors = [NSArray arrayWithObjects:(id)[startColor CGColor],(id)[endColor CGColor], nil];
[self.collectionView.layer insertSublayer:collectionRadient atIndex:0];
但是它绘制在包含图像的单元格上,因此单元格未显示。
我希望能在UICollectionView的单元格下面绘制渐变背景,并且在视图滚动时保持固定。 请告诉我如何实现。