这是我的代码:
[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){
}];
这是旋转前后的图片:
它似乎在旋转之前改变了中心,但我不想要它。
答案 0 :(得分:3)
使用CGAffineTransformMakeRotation(angle)
创建的旋转会使坐标系围绕其原点旋转。文档说“angle =角度,以弧度表示,此矩阵旋转坐标系轴。”
从你的照片看,你的坐标系的原点看起来好像是在方形左上角的某个地方。
如果相应地设置视图的图层anchorPoint
属性,则可以围绕任何其他点旋转。
答案 1 :(得分: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){
}];