我想放慢pickerview的动画速度来模拟老虎机效果。
如何减慢动画速度
[pickerView selectRow:601 inComponent:0 animated:YES];
另外,我怎样才能错开动画,以便组件 1 在组件 0 动画之后进行动画,等等。就像老虎机一样。
我尝试了以下代码来错开旋转,它们似乎都在同时旋转。
- (void) viewDidAppear:(BOOL)animated
{
[UIView beginAnimations:@"reel1" context:nil]; // nil = dummy
[UIPickerView setAnimationDelegate:self];
[UIPickerView setAnimationDidStopSelector:@selector(reelAnimationFinished:finished:context:)];
[reel selectRow:24 inComponent:0 animated:YES];
[UIView commitAnimations];
}
- (void) reelAnimationFinished:(NSString *)animationID finished:(BOOL)finished context:(void *)context {
if (animationID == @"reel1")
{
[UIView beginAnimations:@"reel2" context:nil]; // nil = dummy
[UIPickerView setAnimationDelegate:self];
[UIPickerView setAnimationDidStopSelector:@selector(reelAnimationFinished:finished:context:)];
[reel selectRow:26 inComponent:1 animated:YES];
[UIView commitAnimations];
}
else if (animationID == @"reel2")
{
[reel selectRow:29 inComponent:2 animated:YES];
}
}