iPhone,如何使用核心动画和CATTransferM3D围绕点旋转UIImageView?

iPhone,如何使用核心动画和CATTransferM3D围绕点旋转UIImageView?,iphone,core-animation,transform,Iphone,Core Animation,Transform,这就是我想做的: (1) (2) | / | / | / | / |/ * (3) 我想将由时钟引脚(宽度:9px,高度73px)表示的UIImageView从位置(1)移动到位置(2),围绕点(3)移动,点(3)是图像的一端。 我尝试将主播点设置为(0,0)或将图像中心设置为点(517177),这是iPad屏幕上的*(3)位置,但没有成功: 我的degreeToRadians宏按以下方式定义: #define degreesToRadian(x) (M_PI * (x) / 1

这就是我想做的:

(1) (2) 
|    /
|   /
|  /
| /
|/
*
(3)
我想将由时钟引脚(宽度:9px,高度73px)表示的UIImageView从位置(1)移动到位置(2),围绕点(3)移动,点(3)是图像的一端。 我尝试将主播点设置为(0,0)或将图像中心设置为点(517177),这是iPad屏幕上的*(3)位置,但没有成功:

我的degreeToRadians宏按以下方式定义:

#define degreesToRadian(x) (M_PI * (x) / 180.0)
/* kmPointer是UIImageView */


如何使指针围绕标有(3)的星旋转?

显示定位点图像的Apple文档是针对OSX的。以下是iOS的外观:


因此,请尝试将锚点设置为0.0、1.0。

您确定锚点为(0,0)吗?我想那是左上角,不是左下角。我读了所有这些东西,我尝试了所有的组合,(0.5,0.0),(.0,5),(1,0),(1,1),但仍然没有达到预期的效果。当我放置锚点(1,1)时,我的指针在屏幕上向上移动50像素,并围绕新的(3)点向右旋转。它部分工作,因为旋转是正确的,但在动画开始之前,图像会移动到屏幕上的另一个位置。我想我必须设定一些界限。无论如何,我采用了另一种方法,因为图像围绕中心正确旋转,所以我将图像最大化,使中心成为销底。
NSValue *value = nil;
CABasicAnimation *animation = nil; 
CATransform3D transform;
kmPointer.layer.anchorPoint = CGPointMake(0, 0);
[kmPointer.layer removeAllAnimations]; 
animation = [CABasicAnimation animationWithKeyPath:@"transform"]; 
transform = CATransform3DMakeRotation(degreesToRadian(30), 0.0f, 0.0f, 1.0f); 
value = [NSValue valueWithCATransform3D:transform]; 
[animation setToValue:value]; 
transform = CATransform3DMakeRotation(0.0f, 0.0f, 0.0f, 1.0f); 
value = [NSValue valueWithCATransform3D:transform]; 
[animation setFromValue:value]; 
[animation setAutoreverses:NO]; 
[animation setDuration:1.0f]; 
[animation setRepeatCount:1]; 
[kmPointer.layer addAnimation:animation forKey:nil];