美文网首页
截图功能

截图功能

作者: CHADHEA | 来源:发表于2017-03-10 11:23 被阅读0次

    //.h

    + (UIImage *)screenshotFrom:(UIView *)view frame:(CGRect)frame;

    //.m

    + (UIImage *)screenshotFrom:(UIView *)view frame:(CGRect)frame {

    UIGraphicsBeginImageContext(view.frame.size);

    [view.layer renderInContext:UIGraphicsGetCurrentContext()];

    UIImage      *image=UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

    CGImageRef      cgImage=  CGImageCreateWithImageInRect([image CGImage], frame);

    return [UIImage imageWithCGImage:cgImage];

    }

    谢谢阅读!

    相关文章

      网友评论

          本文标题:截图功能

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