user958880
user958880

Reputation: 497

Monotouch, create a jpg from a UIImageView that has a UIlabel attached

Using Monotouch, I have a UIImageView with some UIlabels attached to him, basically it's an image with some text overlying it, like a postcard. I want to take this image and text and create a jpg/png that is a combination of both.

I have no idea how to do so. Any suggestion?

Upvotes: 1

Views: 176

Answers (1)

Jason
Jason

Reputation: 89214

Craig Dunn has a post that outlines how to programatically do a screen capture. It's older, but I think it will still work.

The core idea is

   UIGraphics.BeginImageContext(View.Frame.Size); 
   var ctx = UIGraphics.GetCurrentContext();
   if (ctx != null)
   {
      View.Layer.RenderInContext(ctx);
      UIImage img = UIGraphics.GetImageFromCurrentImageContext();
      UIGraphics.EndImageContext();
   }

Upvotes: 2

Related Questions