iOS 切屏方法

Posted 原码

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了iOS 切屏方法相关的知识,希望对你有一定的参考价值。

 

点击要切屏时点用此方法获取图片 image 极为切屏图片

- (UIImage *)captureImageFromView:(UIView *)view {

    

    CGRect screenRect = [view bounds];

    UIGraphicsBeginImageContext(screenRect.size);

    CGContextRef ctx = UIGraphicsGetCurrentContext();

    [view.layer renderInContext:ctx];

    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

    return image;

    

}

以上是关于iOS 切屏方法的主要内容,如果未能解决你的问题,请参考以下文章