Sub Page1_Click
Dim no As NativeObject = Me
Dim bmp As Bitmap = no.RunMethod("TakeScreenshot", Null)
Log(bmp)
ImageView1.Bitmap = bmp
End Sub
#If OBJC
- (UIImage*) TakeScreenshot {
UIView *view = [[UIApplication sharedApplication] keyWindow];
float scale = [[UIScreen mainScreen] scale];
CGRect bounds = [[UIApplication sharedApplication] keyWindow].rootViewController.view.bounds;
BOOL shouldRotate = ([[[UIDevice currentDevice] systemVersion] floatValue] < 8.0f && bounds.size.width >= bounds.size.height);
CGSize size = shouldRotate ? CGSizeMake(view.bounds.size.height, view.bounds.size.width) : view.bounds.size;
UIGraphicsBeginImageContextWithOptions(size, YES, scale);
CGContextRef ref = UIGraphicsGetCurrentContext();
UIBezierPath *path = [UIBezierPath bezierPathWithRect:bounds];
[[UIColor whiteColor] setFill];
[path fillWithBlendMode:kCGBlendModeNormal alpha:1];
if (shouldRotate) {
CGContextConcatCTM(ref, CGAffineTransformMakeRotation((CGFloat) -M_PI_2));
CGContextConcatCTM(ref, CGAffineTransformMakeTranslation(-size.height, 0));
}
[view drawViewHierarchyInRect:CGRectMake(0, 0, view.bounds.size.width, view.bounds.size.height) afterScreenUpdates:false];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
#End If