Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何在CABASICANIzation中设置锚点_Ios_Xcode - Fatal编程技术网

Ios 如何在CABASICANIzation中设置锚点

Ios 如何在CABASICANIzation中设置锚点,ios,xcode,Ios,Xcode,我有一个大小为12x44的时钟指针图像。下面的代码是我试图沿时钟方向旋转它的代码 Code : -(void)rotationLargeAnimation:(UIView *) itemView withDuration:(float) durat withDirection:(int)intDirect { CABasicAnimation *rotation1 = [CABasicAnimation animationWithKeyPath:@"transform.rot

我有一个大小为12x44的时钟指针图像。下面的代码是我试图沿时钟方向旋转它的代码

Code :

 -(void)rotationLargeAnimation:(UIView *) itemView withDuration:(float) durat withDirection:(int)intDirect {
        CABasicAnimation *rotation1 = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
        rotation1.fromValue = [NSNumber numberWithFloat:0];
        rotation1.toValue = [NSNumber numberWithFloat:(2*M_PI)];
        rotation1.duration = durat; // Speed
        rotation1.repeatCount = HUGE_VALF; // Repeat forever. Can be a finite number.
         itemView.layer.anchorPoint = CGPointMake(0.5,0.2);
        [itemView.layer addAnimation:rotation1 forKey:@"Spin"];

    }

旋转时钟指针时,它是基于顶部位置旋转的。如何基于底部位置旋转指针。感谢您的帮助。请提前感谢。

定位点设置图层在规范化坐标中旋转的点(0,0)为左上角,(0.5,0.5)为中心(默认),(1.0,1.0)为右下角。所以你可能想把它设置在(0.5,1.0)附近,这是X轴的中心,Y轴的底部(可能会有从底部的偏移,这取决于你的针的形状)