Domanda

I have managed to make the "view" move once. I need for it to stay 1 second in same place and then move back again to initial place. How would I add the rest of the code for this? (This won't be a loop, only done once)

[UIView animateWithDuration:0.8 delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
        [infoView setCenter:CGPointMake(160,30)];
    } completion:nil];
È stato utile?

Soluzione

Use the completion block to do another animation:

[UIView animateWithDuration:0.8 delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
    [infoView setCenter:CGPointMake(160,30)];
} completion:^(BOOL finished) {
    [UIView animateWithDuration:0.8 delay:1 options:UIViewAnimationOptionCurveEaseInOut animations:^{
        [infoView setCenter:CGPointMake(orignalX, originalY)];
    } completion:nil];
}];
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top