How did you able to do that in iOS. Can you give me an idea for the same. Stuck since longtime.
I am doing like this.
var view = UIApplication.SharedApplication.KeyWindow.RootViewController.View.Subviews.FirstOrDefault().Subviews.FirstOrDefault();
UIScrollView scroll = null;
foreach (object subView in view.Subviews)
{
if (subView is UIScrollView)
{
scroll = (UIScrollView)subView;
}
}
UIGraphics.BeginImageContext(scroll.ContentSize);
CGPoint savedContentOffset = scroll.ContentOffset;
CGRect savedFrame = scroll.Frame;
scroll.ContentOffset = CGPoint.Empty;
scroll.Frame = new CGRect(0, 0, scroll.ContentSize.Width, scroll.ContentSize.Height);
scroll.Layer.RenderInContext(UIGraphics.GetCurrentContext());
var image = UIGraphics.GetImageFromCurrentImageContext();
scroll.ContentOffset = savedContentOffset;
scroll.Frame = savedFrame;
UIGraphics.EndImageContext();
using (var imageData = image.AsJPEG(100))
{
var bytes = new byte[imageData.Length];
System.Runtime.InteropServices.Marshal.Copy(imageData.Bytes, bytes, 0, Convert.ToInt32(imageData.Length));
return bytes;
}
It gives null scroll. Please help