0
我正在使用一個簡單的轉換動畫到一個UIIMageView。CAAnimation層取消視圖的previos轉換
[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
開始視圖「跳轉」回到它的原始位置。我怎樣才能防止這種情況發生,爲什麼會這樣呢?
感謝
SHANI
非常感謝,順便說一句我完成後,我打電話給[自setTransform:CGAffineTransformIdentity];到視圖並移除圖層上的所有動畫。下次我嘗試動畫視圖動畫不起作用。螞蟻爲什麼? – shannoga 2012-03-26 15:12:20
我認爲最好是發佈一些代碼來解釋這個問題。另外,如果您認爲這與當前問題無關,最好發佈一個新問題。 – sch 2012-03-26 15:24:45