如何在动画中获取视图坐标?

时间:2016-08-29 15:10:30

标签: ios objective-c cakeyframeanimation

我已创建String并添加了Bezier Cubic路径(带CAShapeLayer功能),并在该曲线的起点上添加了一点视图。之后我创建了addCurveToPoint:controlPoint1:controlPoint2:并将这个小视图从曲线的起点移动到了动画的终点。我希望在动画期间获得该视图的中心点。有任何想法吗?

CAKeyFrameAnimation

`

1 个答案:

答案 0 :(得分:0)

视图图层的function previewFile(){ var preview = document.querySelector('img'); //selects the query named img var file = document.querySelector('input[type=file]').files[0]; //sames as here var reader = new FileReader(); reader.onloadend = function () { preview.src = reader.result; } if (file) { reader.readAsDataURL(file); //reads the data as a URL } else { preview.src = ""; } if (file.width < file.height) { document.getElementById("blah").setAttribute("class", "blahblah"); } else { document.getElementById("blah").setAttribute("class", "profilePic"); } } presentationLayer,可以捕捉图层在动画中间的位置。

例如,如果您想逐帧获取更新,请设置CALayer并检查显示链接处理程序中的CADisplayLink

presentationLayer

使用:

CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
animation.duration = 4.0f;
animation.path = self.bezierPath.CGPath;
animation.delegate = self;                                  // so we know when animation finished
[self startDisplayLink];                                    // start display link
[self.sliderThumb.layer addAnimation:animation forKey:nil];

@property (nonatomic, weak) CADisplayLink *displayLink;