임의의 위치에서collectionView 관성 스크롤 중지
5143 단어 Swift
targetContentOffset 사용
여기를 참고했어요.이게 수직으로 굴러갈 때
PVSCellPagedTableView
UITableView+CellPaging.swift
나는 이 가로판을 만들어 보았다.func pvs_cellPagingScrollViewWillEndDragging(scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>, cellWidth: CGFloat, contentInsetX: CGFloat = 0) {
var targetContentOffsetCorrected: CGPoint = targetContentOffset.memory
targetContentOffsetCorrected.x += contentInsetX
let targetCellIndexPath = self.collectionView?.indexPathForItemAtPoint(targetContentOffsetCorrected)
let targetCellRect = self.collectionView?.cellForItemAtIndexPath(targetCellIndexPath!)
var targetCellXCenter = targetCellRect?.frame.origin.x
println(targetCellXCenter)
let isJumpingDown = (targetContentOffsetCorrected.x % cellWidth) > (cellWidth / 2)
if isJumpingDown == true {
let nextPlace = Int(targetContentOffsetCorrected.x) / Int(cellWidth)
targetCellXCenter = (CGFloat(nextPlace) * cellWidth) + cellWidth
}
if targetCellXCenter != nil {
targetContentOffset.memory.x = targetCellXCenter! - contentInsetX
}
}
Reference
이 문제에 관하여(임의의 위치에서collectionView 관성 스크롤 중지), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/naoyashiga/items/c81dcdcad769a6f8e0aa
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
func pvs_cellPagingScrollViewWillEndDragging(scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>, cellWidth: CGFloat, contentInsetX: CGFloat = 0) {
var targetContentOffsetCorrected: CGPoint = targetContentOffset.memory
targetContentOffsetCorrected.x += contentInsetX
let targetCellIndexPath = self.collectionView?.indexPathForItemAtPoint(targetContentOffsetCorrected)
let targetCellRect = self.collectionView?.cellForItemAtIndexPath(targetCellIndexPath!)
var targetCellXCenter = targetCellRect?.frame.origin.x
println(targetCellXCenter)
let isJumpingDown = (targetContentOffsetCorrected.x % cellWidth) > (cellWidth / 2)
if isJumpingDown == true {
let nextPlace = Int(targetContentOffsetCorrected.x) / Int(cellWidth)
targetCellXCenter = (CGFloat(nextPlace) * cellWidth) + cellWidth
}
if targetCellXCenter != nil {
targetContentOffset.memory.x = targetCellXCenter! - contentInsetX
}
}
Reference
이 문제에 관하여(임의의 위치에서collectionView 관성 스크롤 중지), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/naoyashiga/items/c81dcdcad769a6f8e0aa텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)