RAGOpoR
RAGOpoR

Reputation: 8168

Is it possible to push custom animation with 2 layer?

view 1 is current view
view 2 is view to push

is it possible to

 view 1 draw at top layer
 view 2 draw at bottom layer

move view 1 down to offscreen and at the same time CGAffineTransformMakeScale view 2 from 0.1 to 1.0

how can i do this ?

Update

i want to move all of screen(include navigationController) go down to the bottom of screen. then my problem is when i draw both of this layer at navigationController after i move navigationController down both of this layer will stick with navigationController

how can i make a temporary view to viewTopush(View 2) behind the navigationController and do animate

here is my code but it not yet work.

        RO_GALViewController *galView = [[RO_GALViewController alloc] initWithNibName:@"RO_GALViewController" bundle:nil];


        UINavigationController* navigationController;
        CGRect frame;


        navigationController = [self navigationController];

        frame = [navigationController.view convertRect:self.view.frame fromView:self.view.superview];

        galView.view.frame = frame;
        galView.view.transform = CGAffineTransformMakeScale(0.1,0.1);
        galView.view.alpha = 0;
        UIView *blackView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
        blackView.backgroundColor = [UIColor blackColor];
        blackView.alpha = 0;
        [[self navigationController].view addSubview:blackView];
        [[self navigationController].view addSubview:galView.view];
        [navigationController.view bringSubviewToFront:self.view];

        [UIView animateWithDuration:1.3f
                              delay:0.0f
                            options:UIViewAnimationCurveEaseInOut
                         animations:^{
                             galView.view.alpha = 1.0f;
                             galView.view.transform = CGAffineTransformMakeScale(1.0f, 1.0f);
                             navigationController.view.frame = CGRectMake(self.view.frame.origin.x, 460, self.view.frame.size.width, self.view.frame.size.height);
                         } completion:^(BOOL finished) {
                             [[self navigationController] pushViewController:galView animated:NO];

                         }];

Upvotes: 1

Views: 180

Answers (2)

David Rönnqvist
David Rönnqvist

Reputation: 56635

The tags that you have added to this question (uinavigationcontroller and pushviewcontroller) suggest that you are talking about pushing a new view controller on screen but your description make it sound like both views are two subviews contained in the same view controller...

If you are pushing a new view controller...

You can easily subclass UIStoryboardSegue to create your own animation. In your case you would change the position of the source view controllers view downwards and apply (and animate) the transform of the destination view controllers view. The animations themselves are just like any other animation.

If both views are inside the same view controller...

Just do both animations. You could easily do them both at once using UIView animations, like this

view2.transform = CGAffineTransformMakeScale(0.1, 0.1); // the "from" value
[UIView animateWithDuration:2.0 // animate for 2 seconds
                 animations:^{
    view1.center = view1.center + theDistanceItShouldMoveDown;
    view2.transform = CGAffineTransformIdentity; // no scale
}];

Upvotes: 1

Owen Hartnett
Owen Hartnett

Reputation: 5935

Just put both animations inside your beginAnimations/commitAnimations code section. It will do the animations simultaneously. You don't have to worry about layers.

Upvotes: 1

Related Questions