iOS Screenshot part of the screen

后端 未结 4 2129
野的像风
野的像风 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 10:14

    Use this method to crop if u have image with specfic rect to crop:

    -(UIImage *)cropImage:(UIImage *)image rect:(CGRect)cropRect
    {
       CGImageRef imageRef = CGImageCreateWithImageInRect([image CGImage], cropRect);
       UIImage *img = [UIImage imageWithCGImage:imageRef]; 
       CGImageRelease(imageRef);
       return img;
    }
    

    Use like this:

    UIImage *img = [self cropImage:viewImage rect:CGRectMake(150,150,100,100)]; //example
    

提交回复
热议问题