我正在对 an 执行旋转UIImageView
,然后尝试裁剪其中的一部分并将其另存为UIImage
. 旋转UIImageView
但它总是裁剪照片的相同部分。所以裁剪没有考虑图像旋转。我究竟做错了什么?
//rotate image
CGRect new = CGRectMake(0, 0, 100, 50);
CGAffineTransform rotation = CGAffineTransformMakeRotation(5);
[photo setTransform:rotation];
// crop image
CGImageRef imageRef = CGImageCreateWithImageInRect([photo.image CGImage], new);
UIImage *croppedImage = [UIImage imageWithCGImage:imageRef];
CGImageRelease(imageRef);
// display crop bounds
UIView* faceBounds = [[UIView alloc] initWithFrame:new];
faceBounds.layer.borderWidth = 2;
faceBounds.layer.borderColor = [[UIColor redColor] CGColor];