0
간단한 변환 애니메이션을 UIIMageView에 사용하고 있습니다.CAAnimation 레이어가 뷰의 프리뷰 변환을 취소합니다.
[UIView animateWithDuration:2 delay:0 options:UIViewAnimationOptionBeginFromCurrentState|UIViewAnimationOptionCurveEaseInOut animations:^{
CGAffineTransform translate = CGAffineTransformMakeTranslation(0, -[self percentFromHeight:20]);
clueImage.transform = translate;
} completion:^(BOOL finished) {
[self.cluWordSelectionView setaWordsObjects:[NSArray arrayWithArray:[self.whiteCard clueWordObjectsForSoundAtIndex:self.index]]];
[self addSubview:cluWordSelectionView];
[clueImage.layer addAnimation:[Animations shakeAnimation] forKey:@"shake"];
}];
당신은 완료 후 내가보기에 다른 흔들림 애니메이션 추가하고 볼 수 있듯이 :
[clueImage.layer addAnimation:[Animations shakeAnimation] forKey:@"shake"];
그 다음과 같습니다
+(CAAnimation*)shakeAnimation {
CAKeyframeAnimation* animation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
CGFloat wobbleAngle = 0.06f;
NSValue* valLeft = [NSValue valueWithCATransform3D:CATransform3DMakeRotation(wobbleAngle, 0.0f, 0.0f, 1.0f)];
NSValue* valRight = [NSValue valueWithCATransform3D:CATransform3DMakeRotation(-wobbleAngle, 0.0f, 0.0f, 1.0f)];
animation.values = [NSArray arrayWithObjects:valLeft, valRight, nil];
animation.beginTime = 3;
animation.autoreverses = YES;
animation.duration = 0.125;
animation.repeatCount = HUGE_VALF;
return animation;
}
문제는 그 때 shakeAnimation
뷰가 원래 위치로 "점프"시작합니다. 어떻게 방지 할 수 있습니까? 왜 이런 일이 일어나고 있습니까?
감사
샤니
대단히 감사합니다, BTW 내가 끝나면 [self setTransform : CGAffineTransformIdentity]를 호출합니다. 뷰에 표시하고 레이어의 모든 애니메이션을 제거합니다. 다음에 애니메이션을 시도하고 있는데 뷰 애니메이션이 작동하지 않습니다. 개미 아이디어는 왜? – shannoga
이 문제를 설명하기 위해 몇 가지 코드를 게시하는 것이 좋습니다. 또한 현재의 질문과 독립적이라고 생각하면 새 질문을 게시하는 것이 좋습니다. – sch