Detect swipe up gesture IOS

I know that there is a way to detect the swipe up gesture, but how do I detect a swipe up gesture. I don’t care how long the swipe up gesture is, I just want to do an if statement like this:

public bool nextswipe = false;
if (swipe up gesture) {
     if (nextswipe == false) {
     nextswipe = true;
     //do something
}
} else if (!swipe up gesture) { // no swipe gesture
nextswipe = false;
}

I recommend writing your own boolean function to check if you swiped up on the screen.
Then just put that function into your if statement and check if that’s true.

In my custom function, I calculated the difference between where I pressed on the screen and where I released. If the difference is greater than zero, I considered it as a swipe up gesture.