测试测试 | ✗ |
语言语言 | Obj-CObjective C |
许可证 | MIT |
发布上次发布 | 2016年2月 |
由Nick Donaldson,Michael Gorbach,Alex Rouse,Eric Slosser,Blake Skinner维护。
将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]];
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];
}
你可以使用任意的动画控制器或交互控制器而不需要RZTransitionsManager,只需用iOS7自定义View Controller转场API调用它们即可。
RZTransitions 项目遵循 MIT 许可协议。请参阅 LICENSE
文件以获取详细信息。