获取cell indexPath
:indexPathForItemAtPoint:---根据某一点得到位于这点上的cell的坐标,而且返回值是一个确定的indexPath,而不是数组,正合我意.需要注意的是,这个方法传入的参数point是以scrollView的contentView为坐标系的坐标,使用之前要先进行一次转换.最终我的做法是这样:
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
// 将collectionView在控制器view的中心点转化成collectionView上的坐标
CGPoint pInView = [self.view convertPoint:self.collectionView.center toView:self.collectionView];
// 获取这一点的indexPath
NSIndexPath *indexPathNow = [self.collectionView indexPathForItemAtPoint:pInView];
// 赋值给记录当前坐标的变量
self.currentIndexPath = indexPathNow;
// 更新底部的数据
// ...
}
隐藏导航栏底部的分割线
self.navigationController?.navigationBar.shadowImage = UIImage.init()
网友评论