How to get UIScrollView vertical direction in Swift?
问题 How can I get the scroll/swipe direction for up/down in a VC? I want to add a UIScrollView or something else in my VC that can see if the user swipes/scrolls up or down and then hide/show a UIView depending if it was an up/down gesture. 回答1: If you use an UIScrollView then you can take benefit from the scrollViewDidScroll: function. You need to save the last position (the contentOffset ) it have and the update it like in the following way: // variable to save the last position visited,