Skip to content

Instantly share code, notes, and snippets.

@jfoshee
Last active December 14, 2015 01:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jfoshee/5008117 to your computer and use it in GitHub Desktop.
Save jfoshee/5008117 to your computer and use it in GitHub Desktop.
An RAII style class for setting UIView.AnimationsEnabled MonoTouch / Xamarin.iOS
using System;
using MonoTouch.UIKit;
public sealed class UIViewAnimations : IDisposable
{
public UIViewAnimations(bool enabled)
{
_wasEnabled = UIView.AnimationsEnabled;
UIView.AnimationsEnabled = enabled;
}
public void Dispose()
{
UIView.AnimationsEnabled = _wasEnabled;
}
bool _wasEnabled;
}
@jfoshee
Copy link
Author

jfoshee commented Feb 21, 2013

Use it like this:

using (new UIViewAnimations(false))
    imageView.Frame = GetImageFrame();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment