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