Andrew
Andrew

Reputation: 16051

UIViews not animating when changing between each other

I have 2 views which are the same size, with colourPreview set as a subview of self.view. This is my code for showing the animation:

-(void)startEditingHexLabel {
    [UIView animateWithDuration:0.3
                     animations:^{ 
                         [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:hexTextView cache:YES];
                         [colourPreview removeFromSuperview];
                         [self.view addSubview:hexTextView];
                         [self.view sendSubviewToBack:colourPreview];



                     } 
                     completion:^(BOOL finished){

                         [hexText becomeFirstResponder];
                     }];

}

But it just changes to the new view without a transition. Any ideas?

Upvotes: 0

Views: 223

Answers (1)

Mason
Mason

Reputation: 3597

Have you tried using transitionWithView:duration:options:animations:completion: (docs here). Seems this is preferred in iOS 4.0+. There's an example of how to use it in those docs.

If you want to use your current method, I think forView in [UIView setAnimationTransition:forView:cache:] needs to be the superview of the views you want to animate. In your case, this looks to be self.view. Full docs here.

HTH

Upvotes: 1

Related Questions