뷰가 페이드 인 된 다음 변형 (패닝 및 확대/축소) 한 다음 지연 후 다시 변형 된 다음 키 프레임 애니메이션이 사라지는 키 프레임 애니메이션을 시도하고 있습니다. 내가 겪고있는 문제는 지연 값을 존중하는 대신 첫 번째 변환이 끝난 직후에 두 번째 변환이 시작된다는 것입니다. 이 문제는 변환을 다시 수정할 때만 발생하는 것으로 보입니다. 따라서 애니메이션 키가 허용되지 않는 이유는 이해할 수 없지만 동일한 키 프레임 블록에서 두 개의 다른 변형을 변경하려고 할 때 문제가 발생한다고 의심됩니다. 겹치지 않는다.UIView animateKeyframes가 작동하지 않습니다.
변환 시작 :
[UIView animateKeyframesWithDuration:15.0 delay:0.0 options:UIViewKeyframeAnimationOptionCalculationModeLinear animations:^
{
[UIView addKeyframeWithRelativeStartTime:0.0 relativeDuration:0.1 animations:^
{
self.imageViewCurrent.alpha = 1.0;
}];
[UIView addKeyframeWithRelativeStartTime:0.1 relativeDuration:0.1 animations:^
{
self.imageViewCurrent.transform = self.imageDataCurrent.transform2;
}];
[UIView addKeyframeWithRelativeStartTime:0.5 relativeDuration:0.4 animations:^
{
self.imageViewCurrent.transform = self.imageDataCurrent.transform3;
}];
[UIView addKeyframeWithRelativeStartTime:0.9 relativeDuration:0.1 animations:^
{
self.imageViewCurrent.alpha = 0.0;
}];
}
이 사용되는 변환이다 : 여기
코드이다 (A = 5, B = 0, C = 0, D = 5, TX = 950, TY = 850)transform2 = TX (A = 5, B = 0, C = O, D = 5, 1250 -1500 = TY)
transform3 : (A = 2.5, B = 0, -250 = TX C = 0, D = 2.5, TY = 0)
업데이트 1 : I 자동 레이아웃을 사용하고 있지 않다
.
업데이트 2 :
좀 더 많은 테스트를 수행하고 참으로 두 가지 문제를 일으키는 수정을 변환 것으로 확인되었습니다. 변환 수정 중 하나를 알파로 바꾸면 모든 애니메이션 타이밍이 정상적으로 작동합니다. 지금까지 내가 말할 수있는 한, UIKit 애니메이션이있는 버그입니다. 해결 방법
:
내가 직접 코어 애니메이션을 사용하여, 나는이 문제를 방지 할 수 것으로 나타났습니다. 이 코드는 같은 효과를하지만, 버그없이 생성합니다. "달려"당신은 애니메이션 실행에 마침표 타임 라인을 가지고 같은
// Fade in, pause, fade out.
CAKeyframeAnimation *alphaAnim = [CAKeyframeAnimation animationWithKeyPath:@"opacity"];
alphaAnim.keyTimes = @[@(0.0), @(0.1), @(0.9), @(1.0)];
alphaAnim.values = @[@(0.0), @(1.0), @(1.0), @(0.0)];
alphaAnim.duration = 15.0;
[self.imageViewCurrent.layer addAnimation:alphaAnim forKey:@"opacity"];
// Translate, wait on second translation, translate again.
CAKeyframeAnimation *transformAnim = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
transformAnim.keyTimes = @[@(0.3), @(0.4), @(0.5), @(0.8)];
transformAnim.values = @
[
[NSValue valueWithCATransform3D:CATransform3DMakeAffineTransform(self.imageDataCurrent.transform1)],
[NSValue valueWithCATransform3D:CATransform3DMakeAffineTransform(self.imageDataCurrent.transform2)],
[NSValue valueWithCATransform3D:CATransform3DMakeAffineTransform(self.imageDataCurrent.transform2)],
[NSValue valueWithCATransform3D:CATransform3DMakeAffineTransform(self.imageDataCurrent.transform3)]
];
transformAnim.duration = 15.0;
[self.imageViewCurrent.layer addAnimation:transformAnim forKey:@"transform"];
애니메이션과 관련된 변환이, 아이폰 OS 8 이상한 행동 않습니다. 그냥 분명히 : Autolayout을 사용하고 있습니까? – matt