0

这是我的代码:

[UIView animateWithDuration:0.4f
                      delay:0.1f
                    options:UIViewAnimationOptionCurveEaseOut
                 animations:^{
                     CGAffineTransform rotate = CGAffineTransformMakeRotation( 30.0 / 180.0 * 3.14 );
                     [needleBig setTransform:rotate];

                 }
                 completion:^(BOOL finished){


                 }];

这是旋转前后的图片:
旋转前 旋转后

它似乎在旋转之前改变了中心,但我不想要它。

4

2 回答 2

3

使用创建CGAffineTransformMakeRotation(angle)的旋转使坐标系围绕其原点旋转。文档说“角度=该矩阵旋转坐标系轴的角度,以弧度为单位。”
从您的图片来看,您的坐标系的原点似乎位于时钟所在正方形的左上角。如果相应地设置视图的图层属性,
则可以围绕任何其他点旋转。anchorPoint

于 2013-04-02T21:09:50.890 回答
0

这有效:

needleBig.layer.anchorPoint=CGPointMake(0.5f, 0.5f);

[UIView animateWithDuration:0.4f
                      delay:0.01f
                    options:UIViewAnimationOptionCurveEaseOut
                 animations:^{
                    CGAffineTransform rotate = CGAffineTransformMakeRotation(180.0f * (M_PI / 180.0f));

                    [needleBig setTransform:rotate];



                 }
                 completion:^(BOOL finished){


                 }];
于 2013-04-03T16:27:13.667 回答