objective-c – 在iOS7上使用UINavigationControllerDelegate实
我花了一些时间尝试整理iOS 7中提供的自定义过渡动画.根据
this question,UINavigationControllerDelegate是要走的路.
但是,没有示例或文档描述如何最好地在iOS7中进行简单的垂直过渡. (有一个plethora of other transition styles using
免责声明:我很乐意提供代码,但由于还没有任何代码可以发布…但我创建了一个简单的例子,使用jQuery来展示我想要实现的目标. 看看小提琴 解决方法
不,这不是一个俗气的黑客.那就是你做的.自定义过渡动画只是意味着您负责将新视图带入场景 – 前提是它最终位于正确的位置.因此,从底部对其进行动画处理的方法就是将其放置在底部并将其动画到位. 例如(几乎直接从我书中的示例代码中获取): -(void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext { // boilerplate UIViewController* vc1 = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey]; UIViewController* vc2 = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey]; UIView* con = [transitionContext containerView]; CGRect r1start = [transitionContext initialFrameForViewController:vc1]; CGRect r2end = [transitionContext finalFrameForViewController:vc2]; UIView* v1 = vc1.view; UIView* v2 = vc2.view; // end boilerplate CGRect r = r2end; r.origin.y += r.size.height; // start at the bottom... v2.frame = r; [con addSubview:v2]; [[UIApplication sharedApplication] beginIgnoringInteractionEvents]; [UIView animateWithDuration:0.4 animations:^{ v2.frame = r2end; // ... and move up into place } completion:^(BOOL finished) { [transitionContext completeTransition:YES]; [[UIApplication sharedApplication] endIgnoringInteractionEvents]; }]; } 该代码是根据我在https://github.com/mattneub/Programming-iOS-Book-Examples/blob/master/bk2ch06p292customAnimation1/ch19p620customAnimation1/AppDelegate.m的例子改编的.这个例子几乎就是你所描述的,除了它是一个标签控制器而不是导航控制器,它来自侧面而不是底部.但原则完全一样. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |