两个UIView之间的翻转可以用动画效果翻转(上下,左右)
UIViewController之间的切换除了UINavigationController里面的pushViewController和 popViewController与UITalbarController在viewControllers之间的切换外, 我们还可以在其他地方自由的进行ViewController切换:
MyViewController *_myViewController = [[MyViewController alloc] init];
_myViewController.modalTransitionStyle =UIModalTransitionStyleFlipHorizontal;
[selfpresentModalViewController: _myViewController Animated: YES];
[_myViewController release];
有四种切换形式(modalTransitionStyle):
UIModalTransitionStyleFlipHorizontal
UIModalTransitionStyleCoverVertical (default)
UIModalTransitionStyleCrossDissolve
UIModalTransitionStylePartialCurl
退回方法:[selfdismissModalViewControllerAnimated:YES];
与此对应的是播放视频时:
[selfpresentMediaPlayerViewController:moviePlayer Animated:YES];
[selfdismissMediaPlayerViewControllerAnimated:YES];
========================================
实现UINavigationController视图切换
- (void)dismissModalViewControllerAnimated:(BOOL)animated
- (void)presentModalViewController:(UIViewController *)modalViewController animated:(BOOL)animated
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
- (UIViewController *)popViewControllerAnimated:(BOOL)animated
这4个方法,两两对应,前2个是上下推,后面2个是左右推
实现pushViewController:animated:的不同页面转换特效
1. 首先要明确的是,不使用pushViewController的默认动画,所以在调用这个函数时,要将animated设置为NO.
2. 使用普通的来CATransition实现转换效果,代码如下:
CATransition *animation = [CATransition animation];
[animation setDuration:0.3];
[animation setType: kCATransitionMoveIn];
[animation setSubtype: kCATransitionFromTop];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault]];
[self.navigationController pushViewController:m_poseAddIssueViewController animated:NO];
[self.navigationController.view.layer addAnimation:animation forKey:nil];