Closed zeqinjie closed 3 years ago
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
NSInteger currentIndex = 0;
ZLCollectionViewVerticalLayout* layout = (ZLCollectionViewVerticalLayout*)self.collectionViewLabel.collectionViewLayout;
NSMutableArray* arr = [NSMutableArray new];
[arr addObject:@"0"];
[arr addObjectsFromArray:layout.collectionHeightsArray];
for (NSInteger i = 0; i < arr.count-1; i++) {
CGFloat height1 = [arr[i] floatValue];
CGFloat height2 = [arr[i+1] floatValue];
if (scrollView.contentOffset.y >= height1 && scrollView.contentOffset.y < height2) {
currentIndex = i;
break;
}
}
NSLog(@"当前所在section=%zd", currentIndex);
}
业务中需要监听滚动时候的section 从而设置头部导航栏 title 需求, 使用ZL 不行,但使用系统的layout可以监听到
}