Skip to content

Instantly share code, notes, and snippets.

@ozzieperez
Created July 31, 2015 21:50
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ozzieperez/85cf1d0bad627a6ab928 to your computer and use it in GitHub Desktop.
Save ozzieperez/85cf1d0bad627a6ab928 to your computer and use it in GitHub Desktop.
Xamarin IOS - Returns a UIView as a UIImage
public static UIImage AsImage(this UIView view)
{
UIGraphics.BeginImageContextWithOptions(view.Bounds.Size, true, 0);
view.Layer.RenderInContext(UIGraphics.GetCurrentContext());
var img = UIGraphics.GetImageFromCurrentImageContext();
UIGraphics.EndImageContext();
return img;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment