- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
TaskDetailViewController *detailViewController = segue.destinationViewController;
detailViewController.task = sender;
// create animator object with instance of modal view controller
// we need to keep it in property with strong reference so it will not get release
self.animator = [[ZFModalTransitionAnimator alloc] initWithModalViewController:detailViewController];
self.animator.dragable = YES;
self.animator.direction = ZFModalTransitonDirectionBottom;
[self.animator setContentScrollView:detailViewController.scrollview];
// set transition delegate of modal view controller to our object
detailViewController.transitioningDelegate = self.animator;
// if you modal cover all behind view controller, use UIModalPresentationFullScreen
detailViewController.modalPresentationStyle = UIModalPresentationCustom;
}
如果你的模态中包含 UIScrollView,并且想要通过拖动来关闭模态,你需要将 UIScrollView 设置为 ZFModalTransitionAnimator 实例。
[self.animator setContentScrollView:detailViewController.scrollview];
你可以设置模态呈现的方向。(默认为 ZFModalTransitonDirectionBottom)
self.animator.direction = ZFModalTransitonDirectionBottom;
提示:现在你只能使用 ZFModalTransitonDirectionBottom 设置内容 UIScrollView。
当前的 ViewController 的视图仍然在模态背后可见,因此你只需将背景视图设置为透明颜色。
Amornchai Kanokpullwad,@zoonref
ZFDragableModalTransition 在 MIT 许可证下可用。有关更多信息,请参阅 LICENSE 文件。