Created
October 3, 2017 22:07
-
-
Save hartez/1d168770dbe1e3ba790285abc537dffc to your computer and use it in GitHub Desktop.
Add gesture to off-screen view, animate it onto the screen, gesture still works
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TranslatePage : ContentPage | |
{ | |
public TranslatePage() | |
{ | |
var layout = new RelativeLayout(); | |
var tapGesture = new TapGestureRecognizer | |
{ | |
Command = new Command(() => DisplayAlert("Box Tapped", "The box was tapped", "Cool, thanks.")) | |
}; | |
double boxSize = 100; | |
var box = new BoxView | |
{ | |
HeightRequest = boxSize, | |
WidthRequest = boxSize, | |
BackgroundColor = Color.Red | |
}; | |
layout.Children.Add(box, | |
Constraint.RelativeToParent(parent => -110), | |
Constraint.RelativeToParent(parent => - 110), | |
Constraint.Constant(boxSize), Constraint.Constant(boxSize)); | |
Content = layout; | |
box.GestureRecognizers.Add(tapGesture); | |
var startGesture = new TapGestureRecognizer | |
{ | |
Command = new Command(async () => | |
{ | |
await box.TranslateTo(200, 200); | |
await box.ScaleTo(2); | |
}) | |
}; | |
layout.GestureRecognizers.Add(startGesture); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment