view to image

戚育
2023-12-01

 -(UIImage*)imageByCropping:(UIScrollView*)imageToCrop toRect:(CGRect)rect

{

    CGSize pageSize = rect.size;

    UIGraphicsBeginImageContext(pageSize);

 

    CGContextRef resizedContext =UIGraphicsGetCurrentContext();

    CGContextTranslateCTM(resizedContext,-imageToCrop.contentOffset.x,-imageToCrop.contentOffset.y -73);

    [scrollView.layer renderInContext:resizedContext];

    UIImage*image =UIGraphicsGetImageFromCurrentImageContext();

 

    UIGraphicsEndImageContext();

 

    return image;

}

CGRect clippedRect =CGRectMake(0,0,320,307);

picture.image =[self imageByCropping:myScrollView toRect:clippedRect];

 类似资料:

相关阅读

相关文章

相关问答