I got it to work after following Axel's advice.
Here's the code:
var lastContentOffset: CGPoint!
func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
    lastContentOffset = scrollView.contentOffset
}
func scrollViewWillBeginDecelerating(_ scrollView: UIScrollView) {
    if lastContentOffset.y > scrollView.contentOffset.y {
        print("Going up!")
        if topBarStackView.isHidden == true{
            UIView.animate(withDuration: 0.2, animations: {
                self.topBarStackView.isHidden = false
            })
        }
    } else {
        print("Going down!")
        if topBarStackView.isHidden == false {
            UIView.animate(withDuration: 0.2, animations: {
                self.topBarStackView.isHidden = true
            })
        }
    }
}