let pan = UIPanGestureRecognizer(target: self, action: #selector(handlePanGesture))
self.addGestureRecognizer(pan)
guard gestureRecognizer.view != nil else {return}
let currentPoint = gestureRecognizer.location(in: gestureRecognizer.view!)
if gestureRecognizer.state == UIGestureRecognizerState.began {
startingPoint = currentPoint
}
if gestureRecognizer.state == UIGestureRecognizerState.ended {
endedPoint = currentPoint
if endedPoint.y < startingPoint.y {
isUPscrolling = true
} else { isUPscrolling = false }
Scrolling()
}
fileprivate func Scrolling() {
let distance = CGPoint(x: 0, y: fabs(endedPoint.y - startingPoint.y)).y
if isUPscrolling {
if distance > 30 {
self.setContentOffset(CGPoint(x:0, y:444), animated: true)
} else {
self.setContentOffset(CGPoint(x: 0, y: self.contentOffset.y + distance), animated: true)
}
} else {
if (self.contentOffset.y - distance) < 0 {
self.setContentOffset(CGPoint(x: 0, y: 0), animated: true)
} else {
self.setContentOffset(CGPoint(x: 0, y: self.contentOffset.y - distance), animated: true)
}
}
}
'3D world > Unreal Engine Games Review' 카테고리의 다른 글
Info.plist 에 테스트모드 플래그 넣기 (0) | 2019.01.14 |
---|---|
여러 스크롤 뷰가 겹쳐 있을 때 제스쳐 뒤로 넘기기 (0) | 2019.01.14 |
삼항 연산자는 언제쓸까? (1) | 2019.01.14 |
탭바 컨트롤러 인덱스 알아내기 (0) | 2019.01.14 |
collections removeall() (0) | 2019.01.14 |
최근댓글