Самый простой способ - использовать UIRotationGestureRecognizer
, который дает вам значение поворота в качестве свойства.
Если вы не можете использовать распознаватель жестов, попробуйте что-то вроде этого (не проверено):
// Assuming centerPoint is the center point of the object you want to rotate (the rotation axis),
// currentTouchLocation and initialTouchLocation are the coordinates of the points between
// which you want to calculate the angle.
CGPoint centerPoint = ...
CGPoint currentTouchLocation = ...
CGPoint initialTouchLocation = ...
// Convert to polar coordinates with the centerPoint being (0,0)
CGPoint currentTouchLocationNormalized = CGPointMake(currentTouchLocation.x - centerPoint.x, currentTouchLocation.y - centerPoint.y);
CGPoint initialTouchLocationNormalized = CGPointMake(initialTouchLocation.x - centerPoint.x, initialTouchLocation.y - centerPoint.y);
CGFloat angleBetweenInitialTouchAndCenter = atan2(initialTouchLocationNormalized.y, initialTouchLocationNormalized.x);
CGFloat angleBetweenCurrentTouchAndCenter = atan2(currentTouchLocationNormalized.y, currentTouchLocationNormalized.x);
CGFloat rotationAngle = angleBetweenCurrentTouchAndCenter - angleBetweenInitialTouchAndCenter;
См. Википедию или выполните поиск в Google, чтобы узнать больше о полярных координатах и способах преобразования между декартовой и полярной системами координат.