1
我試圖修改UICollectionView
使用UICollectionViewFlowLayout
來滾動時支持一些視差效果。我能夠通過實現像這樣做的UICollectionViewCells
:滾動時訪問可見的UICollectionReusableViews
- (void)scrollViewDidScroll:(UIScrollView *)mainScrollView
{
CGPoint offset = [mainScrollView contentOffset];
for (UIView *cell in [self.mainCollectionView visibleCells])
if ([cell conformsToProtocol:@protocol(KSParallaxCell)])
[((UIView <GSParallaxCell> *)cell) parallaxInScrollView:mainScrollView toX:offset.x toY:offset.y];
}
是否可以遍歷的補充意見(UICollectionElementKindSectionHeader
和UICollectionElementKindSectionFooter
),以檢查他們是否支持相同的視差代表?