Tôi muốn có thể sử dụng một UIViewAnimationCurve cho phép quay và một thay đổi vị trí khác. Điều này có thể không?Sử dụng hai UIViewAnimationCurves khác nhau trong cùng một hoạt ảnh
Ví dụ: (trong mã giả);
// Begin animations
// Set rotation animation curve to EaseInOut
// Set position animation curve to Linear
// Make some changes to position
// Make some change to the angle of rotation
// Commit the animations
EDIT: (cách tiếp cận CAAnimationGroup gợi ý dưới đây) - Có tạo ra 2 CABasicAnimations riêng biệt và một CAAnimationGroup tuy nhiên các hình ảnh động không được bắt đầu. Bất kỳ ý tưởng?
CABasicAnimation *postionAnimation = [CABasicAnimation animationWithKeyPath:@"position"];
postionAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
postionAnimation.toValue = [NSValue valueWithCGPoint:[self transformPointToWorldSpaceFromViewSpace:self.spriteView.position]];
postionAnimation.delegate = self;
CABasicAnimation *rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.z"];
rotationAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
rotationAnimation.toValue = [NSNumber numberWithFloat:self.spriteView.angle -= M_PI_2];
rotationAnimation.delegate = self;
CAAnimationGroup *animationsGroup = [CAAnimationGroup animation];
animationsGroup.duration = self.clockSpeed;
animationsGroup.animations = [NSArray arrayWithObjects:postionAnimation, rotationAnimation, nil];
// Perform the animation
[self.spriteView.layer addAnimation:animationsGroup forKey:nil];
Đây là lời khuyên tuyệt vời, cảm ơn Duncan. Sẽ cho nó đi vào ngày mai. Dave –
Xin chào Duncan, đã làm điều này và làm việc một điều trị! Câu hỏi duy nhất tôi có là, nó là ok để gọi phương pháp của tôi [tự transformPointToViewSpaceFromWorldSpace: self.spriteView.position] trong khối? Nó hoạt động và các công cụ không hiển thị bất kỳ rò rỉ, tuy nhiên tôi mơ hồ nhớ một cái gì đó về việc sử dụng tự trong khối. Cảm ơn một lần nữa, Dave. –