secondVC *second = [[secondVC alloc] init];動畫
second.modalPresentationStyle = UIModalPresentationCustom;spa
second.transitioningDelegate = 自定義一個代理;代理
[self presentViewController:second animated:YES completion:nil];對象
// MYTransition.hanimation
#import <Foundation/Foundation.h>it
#import <UIKit/UIKit.h>io
#import "Singleton.h"import
@interface MYTransition : NSObject<UIViewControllerTransitioningDelegate>sed
SingletonH(MYTransition)transition
@end
// MYTransition.m
#import "MYTransition.h"
#import "MYPresentationController.h"
#import "MYAnimatedTransition.h"
#import "UIView+MJ.h"
@implementation MYTransition
SingletonM(MYTransition)
#pragma mark - UIViewControllerTransitioningDelegate
- (UIPresentationController *)presentationControllerForPresentedViewController:(UIViewController *)presented presentingViewController:(UIViewController *)presenting sourceViewController:(UIViewController *)source
{
return [[MYPresentationController alloc]initWithPresentedViewController:presented presentingViewController:presenting];
}
- (id <UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source
{
MYAnimatedTransition *anima = [[MYAnimatedTransition alloc]init];
anima.show = YES;
return anima;
}
- (id <UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed
{
MYAnimatedTransition *anima = [[MYAnimatedTransition alloc]init];
anima.show = NO;
return anima;
}
@end
secondVC *second = [[secondVC alloc] init];
second.modalPresentationStyle = UIModalPresentationCustom;
second.transitioningDelegate = [MYTransition sharedMYTransition];
[self presentViewController:second animated:YES completion:nil];