-1

问题:缩放后我可以在固定坐标(50,50,200,200)处裁剪图像吗?我在谷歌上搜索了很多小时,看到了匹配的问题。但没有得到答案。

谢谢。

我的裁剪逻辑在这里..

CGSize itemSize = CGSizeMake(200, 200);
UIGraphicsBeginImageContextWithOptions(itemSize, NO, 0);
CGRect imageRect = CGRectMake(50, 50, 200, 200);
[imageView1.image drawInRect:imageRect];
UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

但我无法在滚动视图中裁剪确切的图像。我想要缩放后在滚动视图中显示的裁剪图像。

4

1 回答 1

0

我自己的问题的答案:谷歌搜索后我找到了一个链接。在这里和经过少许修改后,它对我来说很好。

可能会节省其他人的时间和精力。谢谢

UIGraphicsBeginImageContext(CGSizeMake(200, 200));

[scrollView.layer renderInContext:UIGraphicsGetCurrentContext()];

UIImage *fullScreenshot = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

imageView1.contentMode = UIViewContentModeScaleAspectFill;

UIImageWriteToSavedPhotosAlbum(fullScreenshot, nil, nil, nil);

return fullScreenshot;

import QuartzCore/QuartzCore.h 如果警告

UIGraphicsGetImageFromCurrentImageContext();

于 2012-07-12T11:47:31.013 回答