Это старый вопрос, но другие решения у меня не сработали, поэтому я нашел другое решение:
Поворот изображения - это, по сути, обычное вращение с примененным переводом, гарантирующим, что точка, вокруг которой вы хотите повернуть, все еще остается в том же месте после поворота. Чтобы сделать это, рассчитайте позицию CGPoint в вашем изображении до поворота, получите положение после поворота и примените разницу в качестве перевода к изображению, «привязав» его к правильному положению. Вот код, который я использовал:
Имейте в виду, что перевод должен применяться с помощью CGAffineTransform, а не перемещения .center, потому что перевод должен быть относительно поворота, и CGAffineTransformTranslate () позаботится об этом.
// Note: self is the superview of _imageView
// Get the rotation point
CGPoint rotationPointInSelf = self.center; // or whatever point you want to rotate around
CGPoint rotationPointInImage = [_imageView convertPoint:rotationPointInSelf fromView:self];
// Rotate the image
_imageView.transform = CGAffineTransformRotate(_imageView.transform, angle);
// Get the new location of the rotation point
CGPoint newRotationPointInImage = [_imageView convertPoint:rotationPointInSelf fromView:self];
// Calculate the difference between the point's old position and its new one
CGPoint translation = CGPointMake(rotationPointInImage.x - newRotationPointInImage.x, rotationPointInImage.y - newRotationPointInImage.y);
// Move the image so the point is back in it's old location
_imageView.transform = CGAffineTransformTranslate(_imageView.transform, -translation.x, -translation.y);