1

I am using a solution that I found here to allow my CentralViewController (which inherits from UITableViewController) to determine the scroll direction of its tableView.

extension CentralViewController { // UIScrollViewDelegate
    override func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
        let draggingUp = scrollView.panGestureRecognizer.translation(in: scrollView.superview).y < 0
        tableView.backgroundColor = draggingUp ? .tableCellGradientSecond : .tableCellGradientFirst

        print("Dragging \(draggingUp ? "up" : "down")")
    }
}

The difficulty that I am experiencing is that it is not reliable. If I carefully place my finger and swipe then all is good. But if I quickly place my finger and flick then I sometimes get the wrong direction. Any ideas?

BTW - What I am ultimately after is this: Scrolling the table past the top or bottom reveals the table's background. What I want is that a different color appear at the top than at the bottom. I might resort to a background view.

Verticon
  • 2,129
  • 11
  • 24

0 Answers0