Rotación y recorte de una imagen IOS.
Estoy realizando rotación en unUIImageView
y luego trato de recortar una parte de ella y guardarla como unaUIImage
. losUIImageView
Gira sin embargo siempre recorta la misma parte de la foto. Así que el recorte no tiene en cuenta la rotación de la imagen. ¿Qué estoy haciendo mal?
//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];