我正在使用一个简单的裁剪UIImage
,但是在我们检查最终图像进行裁剪后,它会在 iPhone 中旋转。下面是我用于裁剪的代码。
CGRect visibleRect;
float scale = 1.0f/scrollView.zoomScale;
visibleRect.origin.x = scrollView.contentOffset.x * scale;
visibleRect.origin.y = scrollView.contentOffset.y * scale;
visibleRect.size.width = scrollView.bounds.size.width * scale;
visibleRect.size.height = scrollView.bounds.size.height * scale;
finalImage = imageFromView(displayImageView.image, &visibleRect);
UIImage* imageFromView(UIImage* srcImage, CGRect* rect) {
CGImageRef cr = CGImageCreateWithImageInRect(srcImage.CGImage, *rect);
UIImage* cropped = [UIImage imageWithCGImage:cr];
CGImageRelease(cr);
return cropped;
}
如果我做错了什么,请告诉我。