【发布时间】:2014-01-24 22:16:11
【问题描述】:
我正在尝试从 UINavigationController 呈现 UINavigationController。我正在使用新的 iOS 7 transitioningDelegate 东西,它工作得很好......除了导航栏开始很高,然后在动画结束时缩小。我假设它会缩小,因为条形图没有触及屏幕顶部,但为什么它一开始就很高?我可以防止这种情况吗?
这是动画代码:
- (void)animateTransition:(id <UIViewControllerContextTransitioning>)transitionContext {
UIViewController* fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
UIViewController* toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
UIView* containerView = [transitionContext containerView];
if (toViewController.isBeingPresented) {
[self presentModalView:toViewController.view fromView:fromViewController.view inContainerView:containerView withTransitionContext:transitionContext];
} else {
[self dismissModalView:fromViewController.view fromView:toViewController.view withTransitionContext:transitionContext];
}
}
- (void)presentModalView:(UIView*)modalView fromView:(UIView*)presentationView inContainerView:(UIView*)containerView withTransitionContext:(id<UIViewControllerContextTransitioning>)transitionContext {
[containerView addSubview:modalView];
presentationView.userInteractionEnabled = NO;
modalView.layer.cornerRadius = 5;
modalView.clipsToBounds = YES;
CGRect finalFrame = CGRectInset(presentationView.frame, 10, 20);
modalView.frame = CGRectOffset(finalFrame, 0, CGRectGetHeight(presentationView.frame));
[UIView animateWithDuration:animationDuration animations:^{
modalView.frame = finalFrame;
presentationView.alpha = 0.2;
} completion:^(BOOL finished) {
[transitionContext completeTransition:YES];
}];
}
【问题讨论】:
-
有没有机会也可以添加收缩部分的 GIF?只是想知道到底发生了什么?
-
@TylerFlemingCloutier 是的。我不在我的机器旁,但当我拿到它时我会。基本上,在制作动画时,它的高度太高了 20 像素,完成后它立即(非动画)变为正常大小(想想 iOS 6 导航栏的高度)。
标签: ios objective-c animation ios7 uinavigationcontroller