围绕其左上角旋转矩形

时间:2013-03-05 20:40:44

标签: iphone ios cocoa-touch geometry cgaffinetransform

只需尝试围绕它的原点或左上角旋转一个矩形,如下所示:

enter image description here

使用以下内容:

panGestureRecognizer.view.transform = CGAffineTransformRotate(panGestureRecognizer.view.transform, (M_PI * angle) / 180);

但矩形在一个大循环中旋转。是否需要进行某种翻译才能使其发挥作用?

1 个答案:

答案 0 :(得分:1)

您只需设置锚点:https://developer.apple.com/library/mac/#documentation/graphicsimaging/reference/CALayer_class/Introduction/Introduction.html#//apple_ref/occ/instp/CALayer/anchorPoint

panGestureRecognizer.view.layer.anchorPoint = CGPointMake(0.0, 0.0);

进一步阅读:对于更高级的内容,您可以尝试一下此处详述的矩阵变换提示:https://stackoverflow.com/a/8536553/563381