iOS Screenshot part of the screen

后端 未结 4 2127
野的像风
野的像风 2020-11-29 09:19

I have an App that takes a screenshot of a UIImageView with the following code:

-(IBAction) screenShot: (id) sender{

 UIGraphicsBeginImageContext(sshot.fram         


        
4条回答
  •  悲哀的现实
    2020-11-29 09:58

    From this

    UIGraphicsBeginImageContext(sshot.frame.size);
    CGContextRef c = UIGraphicsGetCurrentContext();
    CGContextTranslateCTM(c, 150, 150);    // <-- shift everything up to required position when drawing.
    [self.view.layer renderInContext:c];
    UIImage* viewImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);
    

提交回复
热议问题