Skip to content

Instantly share code, notes, and snippets.

@martinbowling
Forked from follesoe/AnimationService.cs
Created April 29, 2011 01:00
Show Gist options
  • Save martinbowling/947659 to your computer and use it in GitHub Desktop.
Save martinbowling/947659 to your computer and use it in GitHub Desktop.
MonoTouch animation helper by @alex_york and @follesoe
public static class AnimationService
{
public static void FadeOut(this UIView view, float duration = 1.0f, float opacity = 0.0f)
{
Animate(duration, () => {
view.Layer.Opacity = opacity;
});
}
public static void Animate(double duration, Action block)
{
UIView.BeginAnimations(Guid.NewGuid().ToString());
UIView.SetAnimationDuration(duration);
block();
UIView.CommitAnimations();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment