UIPickerView老虎机通过减慢和错开微调器动画来实现效果

时间:2012-12-31 13:35:08

标签: ios uipickerview

我想降低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];
    }
}

0 个答案:

没有答案