IOS Package modal Animation code

Source: Internet
Author: User

1. Custom transition animations There are a lot of code to write, and if the entire project transitions animation must be consistent, then you must consider encapsulating the modal code.

SECONDVC *second = [[SECONDVC alloc] init];

Second.modalpresentationstyle = Uimodalpresentationcustom;

Second.transitioningdelegate = Customizing an agent;

[Self Presentviewcontroller:second animated:yes completion:nil];

2. Customizing proxy objects

MYTransition.h

#import <Foundation/Foundation.h>

#import <UIKit/UIKit.h>

#import "Singleton.h"

@interface mytransition:nsobject<uiviewcontrollertransitioningdelegate>

Singletonh (mytransition)

@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

3. Using the encapsulated modal animation, it's very simple.

SECONDVC *second = [[SECONDVC alloc] init];

Second.modalpresentationstyle = Uimodalpresentationcustom;

Second.transitioningdelegate = [Mytransition sharedmytransition];

[Self Presentviewcontroller:second animated:yes completion:nil];

IOS Package modal Animation code

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.