-1
我想展示一个简单的点移动。我建立了一个层,设定的范围,位置和颜色,然后用CAAnimation展示其移动为什么CABasicAnimation显示两点移动?
CALayer *l = [CALayer layer];
l.bounds = CGRectMake(0,0,20,20);
l.position = CGPointMake(x,y);
l.cornerRadius = 10;
l.backgroundColor = [UIColor blueColor].CGColor;
[self.theView.layer addSublayer:l];
CABasicAnimation *anim1 = [CABasicAnimation animationWithKeyPath:@"position"];
anim1.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
CGPoint to = CGPointMake(x+dx, y+dy);
anim1.fromValue = [l valueForKey:@"position"];
anim1.toValue = [NSValue valueWithCGPoint:to];
l.position = to;
anim1.duration = 3.0;
当我运行它,我看到两个蓝色圆圈运动。我想看到一个圆从(x,y)移动到(x + dx,y + dy)。有人能告诉我我做错了什么吗?
感谢
谢谢..原来是一个完全无关的问题(drawRect被多次调用 –