美文网首页
UI 开发坑 2021-08-09

UI 开发坑 2021-08-09

作者: iOS打怪升级 | 来源:发表于2021-08-09 17:18 被阅读0次

获取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()

相关文章

网友评论

      本文标题:UI 开发坑 2021-08-09

      本文链接:https://www.haomeiwen.com/subject/emnzvltx.html