美文网首页
UICollectionViewCell自动居于Collecti

UICollectionViewCell自动居于Collecti

作者: 想飞的菜鸟 | 来源:发表于2020-11-25 15:25 被阅读0次
    • (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
      // 非加速中
      if (!decelerate) {
      [self checkCurrentSelect];
      }
      }

    • (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
      [self checkCurrentSelect];
      }

    • (void)checkCurrentSelect {
      CGPoint cellPoint = [self.view convertPoint:self.clCollectionView.center toView:self.clCollectionView];
      NSIndexPath *indexPath = [self.clCollectionView indexPathForItemAtPoint:cellPoint];
      [_clCollectionView selectItemAtIndexPath:indexPath animated:true scrollPosition:UICollectionViewScrollPositionCenteredHorizontally];
      self.currentIndexPath = indexPath;
      }

    相关文章

      网友评论

          本文标题:UICollectionViewCell自动居于Collecti

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