so I have a button and TouchUpInside event already assigned to that button. When the button is pressed, it animates a menu from bottom of the screen to about half of the screen.
But I want the user to be able to swipe UP from WITHIN the button to animate the menu and swipe DOWN from WITHIN the button to animate away.
I was able to figure out up and down swipe gestures but they work on the whole view.
so when user swipes up anywhere on the view, it animates.
How can I get the LocationOfTouch and limit the swipe's starting point from within the button?
This is what I have right now:
I delclared:
UISwipeGestureRecognizer UpSwipe;
UISwipeGestureRecognizer DownSwipe;
And then this is how I used them:
public void setupGestures() {
this.UpSwipe = new UISwipeGestureRecognizer () {
Direction = UISwipeGestureRecognizerDirection.Up,
Enabled = true
};
this.DownSwipe = new UISwipeGestureRecognizer () {
Direction = UISwipeGestureRecognizerDirection.Down,
Enabled = true
};
UpSwipe.AddTarget (animateRecentActivityView);
DownSwipe.AddTarget (animateAwayRecentActivityView);
this.View.AddGestureRecognizer (UpSwipe);
this.View.AddGestureRecognizer (DownSwipe);
}
I was actually able to figure it out. My button was inside a view and even though I added a swipe gesture to the button, somehow it didn't work. Once I removed it from the view, adding swipeGesture to the button directly worked perfectly.
this.UpSwipe = new UISwipeGestureRecognizer () {
Direction = UISwipeGestureRecognizerDirection.Up,
Enabled = true
};
this.DownSwipe = new UISwipeGestureRecognizer () {
Direction = UISwipeGestureRecognizerDirection.Down,
Enabled = true
};
UpSwipe.AddTarget (animateRecentActivityView);
DownSwipe.AddTarget (animateAwayRecentActivityView);
btnAct_HomeRecentActivity.AddGestureRecognizer (UpSwipe);
btnAct_HomeRecentActivity.AddGestureRecognizer (DownSwipe);