简体   繁体   中英

iPhone: How to set animation style for UIView?

Im using the following code to animate the page.

    [UIView a animateWithDuration:0.3
                 animations:^{
                    text.alpha=0;
                 } completion:^(BOOL finished) {
                    //some code
                 }];

Now I want to change the view using some animation style (curl ripple etc). How do I do it?

        [UIView transitionWithView:superView duration:1.0
                       options:UIViewAnimationOptionTransitionCurlUp
                    animations:^{
                        [self.view removeFromSuperview];
                        [superView addSubview:newView];
                    }
                    completion:NULL];

您可能需要设置动画过渡:
[UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration: 1.0]; [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view cache:NO]; //your code [UIView commitAnimations];

//try uiview directly or change uiview as your view in ui viewcontroller

    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:1.0];
    [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self cache:YES];
    [UIView commitAnimations];

I've correct it to work in alternative to superview:

[UIView transitionWithView:self.parentViewController.view duration:1.0
                           options:UIViewAnimationOptionTransitionCurlUp
                        animations:^{
                            [self.view removeFromSuperview];
                            [self.parentViewController.view addSubview:self.newVC.view];
                        }
                        completion:NULL];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM