我为动画制作的以下方法:
-(void)shakingAnimationForGate:(UIImageView *)image leftShaking:(CGAffineTransform)leftTransform rightShaking:(CGAffineTransform)rightTransform animationName:(NSString *)string{
[UIView animateWithDuration:5.0
delay:0.5
options: UIViewAnimationOptionCurveEaseOut
animations:^{
image.transform = leftTransform; // starting point
[UIView beginAnimations:string context:(__bridge void *)(image)];
[UIView setAnimationRepeatAutoreverses:YES]; // important
[UIView setAnimationRepeatCount:20];
[UIView setAnimationDelay:0.1];
[UIView setAnimationDuration:0.06];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(shakeEnded:finished:context:)];
image.transform = rightTransform; // end here & auto-reverse
[UIView commitAnimations];
}
completion:^(BOOL finished){
NSLog(@"end of shaking");
}];
}
这让UIView做了“摇晃”。
然后我正在使用这种方法:
CGAffineTransform leftShake = CGAffineTransformMakeTranslation(-2, 6);
CGAffineTransform rightShake = CGAffineTransformMakeTranslation(0, 3);
[self shakingAnimationForGate:imageLeft leftShaking:leftShake rightShaking:rightShake animationName:@"left view shake"];
imageLeft 是 UIImageView 。
所以我的问题是这个方法不会在iOS 6.1上做动摇动画。它在iOS 7上工作正常。有什么想法是什么问题?
答案 0 :(得分:0)
编译时,Xcode会稍微优化您的代码。例如,如果执行以下代码,则只执行最后一行:
[self.view setBackgroundColor:[UIColor greenColor]];
[self.view setBackgroundColor:[UIColor yellowColor]];
很可能也是动画的情况。
将还原部件移动到完成部件。