Pergunta

I guess this is quite basic, but I was wondering if there is an easy way to animate an entire NIB onto the screen... coming from the right. Ideally, I'd like it to bounce a bit once it stops (i.e. if the NIB is supposed to scroll to position X = 0, I'd like to go it slightly negative before coming back to 0).

This is what I have so far:

                         [UIView animateWithDuration:0.5
                                           delay:0
                                         options:UIViewAnimationOptionCurveEaseIn
                                      animations:^{


                                          TabsEdit *tEdit = [[TabsEdit alloc] initWithNibName:@"TabsEdit" bundle:nil];
                                          self.tabsEdit = tEdit;
                                          [self.view addSubview:tEdit.view];
                                          [tEdit release];



                                      }
                                      completion:^(BOOL finished){

                                      }

Is there any easy solution or will I need to animate every single element in the NIB into view and then add my little bounce effect to it?

I'd be grateful for any suggestions of how to achieve this efficiently.

Foi útil?

Solução

To get more complicated animations (if you want to have more segments to the bouce), you should go down to the CoreAnimation layer and define keyframes. Else have a series of embedded animateWithDuration/Completions, with each one doing a different part of the bounce). If all elements of a view are subviews, then when the view is animated, its subviews will follow.

Outras dicas

one move repeat to bounce.

    [UIView beginAnimations:@"move" context:nil];
    [UIView setAnimationBeginsFromCurrentState:YES];
    [UIView setAnimationDuration:0.25];
    [UIView setAnimationCurve:UIViewAnimationCurveLinear];
    if(movingIn){
        view.frame = CGRectMake(0.0f, view.frame.origin.x, .view.frame.size.width, view.frame.size.height);
    }else{
        view.frame = CGRectMake(320.0f, view.frame.origin.x, .view.frame.size.width, view.frame.size.height);
    }

    [UIView commitAnimations];
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top