Как выполнить несколько анимаций подряд? - PullRequest
0 голосов
/ 03 июля 2010
-(ibaction)sometouched:(id)sender
{
    [UIView beginAnimations:@"first one" context:nil];
    [UIView setAnimationDuration:1.0];
    [myview setFrame:CGRectMake(0,y,width.height.);
    [UIView commitAnimations];

    [UIView beginAnimations:@"second one" context:nil];
    [UIView setAnimationDuration:1.0];
    [myview setFrame:CGRectMake(x,0,width.height.);
    [UIView commitAnimations];
}

Это просто демонстрация. Что я хочу, так это то, что анимация займет 2 части. первый перемещает вид вниз, а второй - вправо. но то, что у меня есть, это то, что оно быстро опускается, а затем движется вправо.

что мне здесь не хватало?

1 Ответ

1 голос
/ 03 июля 2010

Вам необходимо запустить вторую анимацию из метода делегата animationDidStop.

-(ibaction)sometouched:(id)sender
{
    [UIView beginAnimations:@"first one" context:nil];
    [UIView setAnimationDuration:1.0];
    [myview setFrame:CGRectMake(0,y,width.height.);
    [UIView setAnimationDelegate:self];
    [UIView commitAnimations];
}

- (void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag {
    [UIView beginAnimations:@"second one" context:nil];
    [UIView setAnimationDuration:1.0];
    [myview setFrame:CGRectMake(x,0,width.height.);
    [UIView setAnimationDelegate:nil];
    [UIView commitAnimations];
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...