iphone - 如何获得图层点?

标签 iphone cocoa core-animation

我使用此代码来旋转指针(就像在速度计中一样):

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"];

现在我的问题是,在动画过程中,我按下一个按钮,此时针会返回到特定点上移动。所以当我触摸按钮时我必须得到最后一层的点。

如何获取图层的最后一个点?

最佳答案

你的问题很难理解,但看起来你是在问如何确定用户按下按钮时进度动画的状态。为此,您可以获得 CALayerpresentationLayer ,并查询正在动画的属性的当前值。

this question 的答案向您展示如何确定旋转的presentationLayer 的角度。您可能想忽略我不必要的复杂答案。

关于iphone - 如何获得图层点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1434639/

相关文章:

iphone - 将HTTP响应转换为字符串后,EXC_BAD_ACCESS

iphone - Objective-C 错误

objective-c - 自定义格式化程序奇怪的行为

ios - CAShapeLayer 动画 lineCap 属性

iphone - 如何在旋转 90 度后将图像添加到 CALayer 的背面?

iphone - 日历中的EKEvent如何设置不闹钟

iphone - 如何使用\t [tab] 运算符在列中格式化 NSString?

objective-c - Cocoa 中一系列图像之间动画的不同方式

iphone - 使用正则表达式验证文本字段

macos - 响应 keyDown 事件的最佳实践