Я анимирую свой UIImageView с помощью CAAnimation, используя свойство layer следующим образом:
[imageView.layer addAnimation:pathAnimation forKey:[NSString stringWithFormat:@"pathAnimation%@",objId]];
Но в конце моей анимации (после того, как объект переместился из исходной точки), когда я читаю координаты X Y или центра фрейма, они всегда кажутся оригинальными, а не теми, куда переместился объект.
Как прочитать координаты слоя, чтобы определить правильное местоположение моего движущегося объекта?
Вот мой код:
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 50, 50)];
imageView.image = [UIImage imageNamed:@"banner1.jpg"];
imageView.animationDuration = 2;
imageView.animationRepeatCount = 0;
imageView.tag = 100000;
imageView.layer.frame = imageView.frame;
[self.view addSubview:imageView];
CAKeyframeAnimation *pathAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
pathAnimation.duration = 2.0f;
pathAnimation.delegate=self;
pathAnimation.calculationMode = kCAAnimationPaced;
pathAnimation.fillMode = kCAFillModeForwards;
pathAnimation.removedOnCompletion = NO;
CGMutablePathRef pointPath = CGPathCreateMutable();
CGPathMoveToPoint(pointPath, NULL, 100, 100);
CGPathAddLineToPoint(pointPath, NULL, 300, 200);
CGPathAddLineToPoint(pointPath, NULL, 200, 150);
pathAnimation.path = pointPath;
CGPathRelease(pointPath);
[imageView.layer addAnimation:pathAnimation forKey:@"pathAnimation"];
[imageView release];