开发者

UIViews not animating when changing between each other

开发者 https://www.devze.com 2023-02-22 03:09 出处:网络
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:

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 witho开发者_JS百科ut a transition. Any ideas?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消