转场动画涉及到的包括导航控制器的Push动画和Pop动画,以及普通控制器的Present和Dismiss动画,主要就是通过控制器遵守UIViewControllerTransitioningDelegate,并实现对应的方法,返回一个遵守UIViewControllerAnimatedTransitioning协议的对象,而主要的动画实现就是写在这个对象当中~
__ 如果是Push和pop动画需要再push控制器和pop时的控制器里同时实现导航控制器的代理以实现Push和Pop的动画,而Present和Dismiss动画只需要在Presnent的时候设置代理,并实现present和dismiss的协议方法就OK了 __
__ 为了方便使用,一般会封装代理返回的动画协议对象(UIViewControllerAnimatedTransitioning),通过之类来进一步处理各种各样的转场动画 __
//
// ViewController.m
// transitionDemo
// Copyright © 2016年 SSBun. All rights reserved.
//
#import "ViewController.h"
#import "TwoViewController.h"
#import "PushAnimator.h"
#import "PresentAnimator.h"
#import "DismissAnimator.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
self.navigationController.delegate = self;
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{