Improve UIScreen Capture() support for complex views (#1235)

Use DrawViewHierarchy to capture a snapshot of the current screen
This commit is contained in:
Christian Resma Helle 2016-11-24 16:30:33 +01:00 коммит произвёл Rolf Bjarne Kvinge
Родитель 77d4769f54
Коммит cf07825667
1 изменённых файлов: 12 добавлений и 0 удалений

Просмотреть файл

@ -37,6 +37,18 @@ namespace XamCore.UIKit {
public UIImage Capture ()
{
if (UIDevice.CurrentDevice.CheckSystemVersion (7, 0)) {
// This is from https://developer.apple.com/library/content/qa/qa1817/_index.html
try {
var view = UIApplication.SharedApplication.KeyWindow;
UIGraphics.BeginImageContextWithOptions (view.Bounds.Size, view.Opaque, 0);
view.DrawViewHierarchy (view.Bounds, true);
return UIGraphics.GetImageFromCurrentImageContext ();
} finally {
UIGraphics.EndImageContext ();
}
}
// This is from: https://developer.apple.com/library/ios/#qa/qa2010/qa1703.html
var selScreen = new Selector ("screen");
var size = Bounds.Size;