2010-03-26 116 views

回答

7

您需要翻译的起源到要绕点,做旋转,然后翻译回原点:

@implementation NSAffineTransform (Rotation) 
+ (NSAffineTransform *)transformRotatingAroundPoint:(NSPoint) p byDegrees:(CGFloat) deg 
{ 
    NSAffineTransform * transform = [NSAffineTransform transform]; 
    [transform translateXBy: p.x yBy: p.y]; 
    [transform rotateByDegrees:deg]; 
    [transform translateXBy: -p.x yBy: -p.y]; 
    return transform; 
} 
@end 
+0

感谢罗布乌拉圭回合的建议。它确实解决了。 – boom

+0

如何在用户移动触摸iphone时旋转图像?任何教程或代码或URL或示例? – Satyam

+0

不能通过更改锚点来完成此操作吗? –