Created
January 19, 2017 16:09
-
-
Save danwaters/7666a830402834c18e950cf6b67c91bf to your computer and use it in GitHub Desktop.
A little animated popup message that attaches to any AbsoluteLayout and displays in the center.
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 static class Popper | |
{ | |
public async static Task Pop (string message, AbsoluteLayout attachLayout, int showforMilliseconds = 1500) | |
{ | |
var container = new StackLayout | |
{ | |
HorizontalOptions = LayoutOptions.Center, | |
VerticalOptions = LayoutOptions.Center, | |
BackgroundColor = Color.FromHex ("#DDEFEFEF"), | |
Padding = 10 | |
}; | |
var label = new Label | |
{ | |
Text = message, | |
FontAttributes = FontAttributes.Bold, | |
Style = (Style)Application.Current.Resources["PopupText"] | |
}; | |
container.Children.Add (label); | |
container.Scale = 0; | |
container.Opacity = 0; | |
attachLayout.Children.Add (container, attachLayout.Bounds, AbsoluteLayoutFlags.PositionProportional); | |
container.ScaleTo (1.0f, 100); | |
container.FadeTo (1.0f, 100); | |
await Task.Delay (showforMilliseconds); | |
container.ScaleTo (0.0f, 250); | |
await container.FadeTo (0.0f, 250); | |
attachLayout.Children.Remove (container); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment