美文网首页
UICollectionView粘性滑动

UICollectionView粘性滑动

作者: 然亦伞 | 来源:发表于2018-03-22 11:02 被阅读45次

    1、在UICollectionViewFlowLayout子类里重写

    - (CGPoint)targetContentOffsetForProposedContentOffset:(CGPoint)proposedContentOffset withScrollingVelocity:(CGPoint)velocity;
    这个方法用于设置滑动停止时的位置,proposedContentOffset代表将要停止的位置,velocity代表现在滑动的速度
    

    http://www.cnblogs.com/fengtengfei/p/5100925.html

    2、占位的scrollView(专门用来翻页用的),对占位scrollView设置pagingEnabled=YES,占位scrollView的宽度设置为想要一次滑动的距离,再修改则hitTest方法,让占位滚动视图以外的点击事件都能被占位视图接收到。

    - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
        return self.placeholderSV;
    }
    

    https://www.jianshu.com/p/6d39209f9051

    相关文章

      网友评论

          本文标题:UICollectionView粘性滑动

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