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;

    

}

posted @ 2017-05-26 11:27  原码  阅读(438)  评论(0编辑  收藏  举报