Skip to content

Instantly share code, notes, and snippets.

@dvdsgl
Created August 25, 2013 19:02
Show Gist options
  • Save dvdsgl/6335596 to your computer and use it in GitHub Desktop.
Save dvdsgl/6335596 to your computer and use it in GitHub Desktop.
Task Animate (double duration, Action animation)
{
var complete = new TaskCompletionSource<object> ();
UIView.Animate (duration, () => animation (), () => {
complete.TrySetResult (null);
});
return complete.Task;
}
async void Dismiss ()
{
await Animate (0.2, () => {
ControlView.Alpha = 0;
CoverView.Frame = CoverOrigin;
BackgroundView.Alpha = 1;
});
// Notify listeners so we can be fully dismissed
Dismissed ();
}
public override async void ViewDidAppear (bool animated)
{
ControlView.Alpha = 0;
CoverView.Frame = CoverOrigin;
BackgroundView.Alpha = 1;
await Animate (0.2, () => {
CoverView.Frame = CoverDestination;
BackgroundView.Alpha = 0;
});
await Animate (0.2, () => {
ControlView.Alpha = 1;
});
base.ViewDidAppear (false);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment