我使用此代码来旋转指针(就像在速度计中一样):
CALayer* layer = someView.layer;
CABasicAnimation* animation;
animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
animation.fromValue = [NSNumber numberWithFloat:0.0 * M_PI];
animation.toValue = [NSNumber numberWithFloat:1.0 * M_PI];
animation.duration = 1.0;
animation.cumulative = YES;
animation.repeatCount = 1;
animation.removedOnCompletion = NO;
animation.fillMode = kCAFillModeForwards;
[layer addAnimation:rotationAnimation forKey:@"transform.rotation.z"];
现在我的问题是,在动画过程中,我按下一个按钮,此时针会返回到特定点上移动。所以当我触摸按钮时我必须得到最后一层的点。
如何获取图层的最后一个点?
最佳答案
你的问题很难理解,但看起来你是在问如何确定用户按下按钮时进度动画的状态。为此,您可以获得 CALayer
的 presentationLayer ,并查询正在动画的属性的当前值。
this question 的答案向您展示如何确定旋转的presentationLayer 的角度。您可能想忽略我不必要的复杂答案。
关于iphone - 如何获得图层点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1434639/