IOS custom scene switching animation ., Ios custom scenario Switching

Source: Internet
Author: User

IOS custom scene switching animation ., Ios custom scenario Switching

In IOS, we can use Storyborad And segue to implement our own scene switching animation, create a project, use the Single View Application template, and name it MyCustomSegue.

Use storyboard to export another UIViewController, set the View color of the two controllers, and set the seue to custom for the jump page.

    

  

Set

  

Create the MyCustomChangeSegue file and re-execute the perform method.

  

 1 @implementation MyCustomChangeSegue 2  3 -(void)perform 4 { 5     UIViewController *sourceViewController = self.sourceViewController; 6     UIViewController *destViewController = self.destinationViewController; 7      8     [UIView animateWithDuration:1 animations:^{ 9         CGPoint centerPoint = sourceViewController.view.center;10         sourceViewController.view.frame = CGRectMake(centerPoint.x,centerPoint.y , 0, 0);11         sourceViewController.view.alpha = 0;12     } completion:^(BOOL success){13         UIView *destView = destViewController.view;14         sourceViewController.view.hidden = YES;15         [[sourceViewController.view superview] addSubview:destView];16         CGRect destRect = destView.frame;17         CGPoint centerPoint = destView.center;18         destView.frame = CGRectMake(centerPoint.x,centerPoint.y , 0, 0);19         destView.alpha = 0;20         [UIView animateWithDuration:0.3 animations:^{21             destView.frame = destRect;22             destView.alpha = 1;23         } completion:^(BOOL success){24             destView.alpha = 1;25             destView.frame = destRect;26             sourceViewController.view.hidden = NO;27             [sourceViewController presentViewController:destViewController animated:NO completion:nil];28         }];29     }];30 }31 32 @end

 

Click the go button to run the program, and we will see the magic!

  

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.