iOS 切换控制器:JTMaterialTransition

bgn4 9年前

JTMaterialTransition 是基于谷歌 material design 的 iOS 切换控制器。

#import <UIKit/UIKit.h>    // You have to implement UIViewControllerTransitioningDelegate protocol  @interface ViewController : UIViewController<UIViewControllerTransitioningDelegate>  @end    #import "ViewController.h"    #import <JTMaterialTransition.h>  #import "SecondViewController.h"    @implementation ViewController    @interface ViewController ()    @property (nonatomic) JTMaterialTransition *transition;  @property (nonatomic) UIButton *presentControllerButton;    @end    @implementation ViewController    - (void)viewDidLoad  {      [super viewDidLoad];        // No specific moment to call this method, just before presenting a controller      [self createTransition];  }    - (void)didPresentControllerButtonTouch  {      // The controller you want to present      UIViewController *controller = [SecondViewController new];        // Indicate you use a custom transition      controller.modalPresentationStyle = UIModalPresentationCustom;      controller.transitioningDelegate = self;        [self presentViewController:controller animated:YES completion:nil];  }    // Initialize the tansition  - (void)createTransition  {      // self.presentControllerButton is the animatedView used for the transition      self.transition = [[JTMaterialTransition alloc] initWithAnimatedView:self.presentControllerButton];  }    // Indicate which transition to use when you this controller present a controller  - (id<UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented                                                                    presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source  {      self.transition.reverse = NO;      return self.transition;  }    // Indicate which transition to use when the presented controller is dismissed  - (id<UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed  {      self.transition.reverse = YES;      return self.transition;  }  @end

iOS 切换控制器:JTMaterialTransition

项目主页:http://www.open-open.com/lib/view/home/1430831432491