RZTransitions 1.2.1

RZTransitions 1.2.1

测试测试
语言语言 Obj-CObjective C
许可证 MIT
发布上次发布2016年2月

Nick DonaldsonMichael GorbachAlex RouseEric SlosserBlake Skinner维护。




RZTransitions是一个库,可以帮助制作iOS7自定义View Controller转场更加顺畅和简单。


Overview

安装

手动安装

RZTransitions目录(及其子目录)中的所有文件复制并添加到你的项目中。

设置新的默认转场

Swift

RZTransitionsManager.shared().defaultPresentDismissAnimationController = RZZoomAlphaAnimationController()
RZTransitionsManager.shared().defaultPushPopAnimationController = RZCardSlideAnimationController()

Objective C

id<RZAnimationControllerProtocol> presentDismissAnimationController = [[RZZoomAlphaAnimationController alloc] init];
id<RZAnimationControllerProtocol> pushPopAnimationController = [[RZCardSlideAnimationController alloc] init];
[[RZTransitionsManager shared] setDefaultPresentDismissAnimationController:presentDismissAnimationController];
[[RZTransitionsManager shared] setDefaultPushPopAnimationController:pushPopAnimationController];

当显示View Controller时

Swift

self.transitioningDelegate = RZTransitionsManager.shared()
let nextViewController = UIViewController()
nextViewController.transitioningDelegate = RZTransitionsManager.shared()
self.presentViewController(nextViewController, animated:true) {}

Objective C

[self setTransitioningDelegate:[RZTransitionsManager shared]];
UIViewController *nextViewController = [[UIViewController alloc] init];
[nextViewController setTransitioningDelegate:[RZTransitionsManager shared]];
[self presentViewController:nextViewController animated:YES completion:nil];

当创建导航控制器(或使用RZTransitionsNavigationController)时

Swift

let navigationController = UINavigationController()
navigationController.delegate = RZTransitionsManager.shared()

Objective C

UINavigationController *navigationController = [[UINavigationController alloc] init];
[navigationController setDelegate:[RZTransitionsManager shared]];

为特定View Controller指定转场

Swift

RZTransitionsManager.shared().setAnimationController( RZZoomPushAnimationController(),
    fromViewController:self.dynamicType,
    toViewController:RZSimpleCollectionViewController.self,
    forAction:.PushPop)

Objective C

// Use the RZZoomPushAnimationController when pushing from this view controller to a
// RZSimpleCollectionViewController or popping from a RZSimpleCollectionViewController to
// this view controller.
[[RZTransitionsManager shared] setAnimationController:[[RZZoomPushAnimationController alloc] init]
                                   fromViewController:[self class]
                                     toViewController:[RZSimpleCollectionViewController class]
                                            forAction:RZTransitionAction_PushPop];

连接交互器

Swift

override func viewDidLoad() {
    super.viewDidLoad()

    self.presentInteractionController = RZVerticalSwipeInteractionController()
    if let vc = self.presentInteractionController as? RZVerticalSwipeInteractionController {
        vc.nextViewControllerDelegate = self
        vc.attachViewController(self, withAction:.Present)
    }
}

override func viewWillAppear(animated: Bool)
{
    super.viewWillAppear(animated)
    RZTransitionsManager.shared().setInteractionController( self.presentInteractionController,
        fromViewController:self.dynamicType,
        toViewController:nil,
        forAction:.Present)
}

Objective C

@property (nonatomic, strong) id<RZTransitionInteractionController> presentInteractionController;

- (void)viewDidLoad
{
   [super viewDidLoad];
    // Create the presentation interaction controller that allows a custom gesture
    // to control presenting a new VC via a presentViewController
   self.presentInteractionController = [[RZVerticalSwipeInteractionController alloc] init];
   [self.presentInteractionController setNextViewControllerDelegate:self];
   [self.presentInteractionController attachViewController:self withAction:RZTransitionAction_Present];
}

- (void)viewWillAppear:(BOOL)animated
{
   [super viewWillAppear:animated];
    //  Use the present interaction controller for presenting any view controller from this view controller
   [[RZTransitionsManager shared] setInteractionController:self.presentInteractionController
                                        fromViewController:[self class]
                                          toViewController:nil
                                                 forAction:RZTransitionAction_Present];
}

功能特点

  • 丰富的动画控制器库
  • 丰富的交互控制器库
  • 混合匹配任意动画控制器和交互控制器
  • 共享实例管理器,帮助将iOS7自定义转场协议封装,以提供更友好的API

你可以使用任意的动画控制器或交互控制器而不需要RZTransitionsManager,只需用iOS7自定义View Controller转场API调用它们即可。

维护者

arrouse (@arrouse88)

nbonatsakis (@nickbona)

dostrander (@_Derko)

markpragma (@markpragma )

rztakashi

贡献者

smbarne (@smbarne)

许可

RZTransitions 项目遵循 MIT 许可协议。请参阅 LICENSE 文件以获取详细信息。