iOS开发之截取UIScrollView长图方法、截长图

/** 获取scrollView的长截图*/
- (UIImage *)getLongImage:(UIScrollView *)scrollView
{
    UIGraphicsBeginImageContextWithOptions(scrollView.contentSize, NO, [UIScreen mainScreen].scale);
    //这里需要你修改下layer的frame,不然只会截出在屏幕显示的部分
    scrollView.layer.frame = CGRectMake(0, 0, scrollView.contentSize.width, scrollView.contentSize.height);
    [scrollView.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return image;
}
posted @ 2019-12-27 17:22  kawerd  阅读(2369)  评论(0编辑  收藏  举报