我有一个 UICollectionView,我正在按照此链接实现粘性 header :http://blog.radi.ws/post/32905838158/sticky-headers-for-uicollectionview-using#notes
它的效果非常好,但是我的窗口应用了背景图像,而我的标题 View 具有透明背景。因此,当我的项目滚动到标题 View 上方时,您仍然可以看到它们。
理想情况下,我会用渐变淡出单元格,直到它出现在标题 View 后面时才看不见。
谢谢。
最佳答案
您还没有发布任何代码,所以这里是一个不看代码的尝试。只需在您的 UICollectionView
的 super View 上设置一个 mask 层,您就可以开始了:
CAGradientLayer *gradient = [CAGradientLayer layer];
gradient.frame = self.collectionView.superview.bounds;
gradient.colors = @[(id)[UIColor clearColor].CGColor, (id)[UIColor blackColor].CGColor];
// Here, percentage would be the percentage of the collection view
// you wish to blur from the top. This depends on the relative sizes
// of your collection view and the header.
gradient.locations = @[@0.0, @(percentage)];
self.collectionView.superview.layer.mask = gradient;
要使此解决方案正常工作,您必须将 Collection View 嵌入到它自己的 super View 中。
有关图层蒙版的更多信息,请查看 the documentation.
关于ios - 淡出 UICollectionView 中的项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24491250/