美文网首页
iOS截取指定区域的图

iOS截取指定区域的图

作者: super_2e20 | 来源:发表于2019-03-25 17:32 被阅读0次

    info 加相册权限
    UIImage *iamge =[self screenShotView:self.scrollView];
    UIImageWriteToSavedPhotosAlbum(iamge, self, @selector(image:didFinishSavingWithError:contextInfo:), (__bridge void *)self);

    • (UIImage )screenShotView:(UIView)view{
      UIImage *image = [[UIImage alloc]init];
      CGSize size;
      size.width = SCREEN_WIDTH;
      size.height = FIT(170);
      UIGraphicsBeginImageContextWithOptions(size, false, 0.0);
      [view.layer renderInContext:UIGraphicsGetCurrentContext()];
      image = UIGraphicsGetImageFromCurrentImageContext();
      UIGraphicsEndImageContext();
      return image;
      }

    pragma mark -- <保存到相册>

    -(void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo {
    NSString *msg = nil ;
    if(error){
    msg = @"保存图片失败" ;
    }else{
    msg = @"保存图片成功" ;
    }
    }

    相关文章

      网友评论

          本文标题:iOS截取指定区域的图

          本文链接:https://www.haomeiwen.com/subject/etubvqtx.html