iOS Question this example take screenshot ..Any note?

naifnas

Active Member
Licensed User
hi all
this example take screenshot for app
please if you have any note tell me..
thanks

B4X:
Sub Button1_Click
    Dim noMe As NativeObject=Me
    Log("getScrhotImage")
    ' remove it
    ImageView1.Bitmap= noMe.runMethod("getScrhotImage",Null)

End Sub
#If OBJC

-(UIImage *)getScrhotImage
{

        CGRect scrRect = [[UIScreen mainScreen] bounds];
        UIGraphicsBeginImageContext(scrRect .size);
        CGContextRef ctx = UIGraphicsGetCurrentContext();
        [[UIColor blackColor] set];
        CGContextFillRect(ctx, scrRect );

          UIWindow *veiw= [UIApplication sharedApplication].keyWindow;

  
        [veiw.layer renderInContext:ctx];
        UIImage *image= UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();
          UIGraphicsEndImageContext();

        return image;
}
#end if
 
Top