我正在進行自定義目前和解僱過渡,並有一些問題。我想要做的是在iOS 7中重複這個很酷的深度動畫(當我們打開/關閉一些應用程序時)。 我有第一和第二控制器。所有動畫都在第一個控制器中(它支持UIViewControllerTransitioningDelegate和UIViewControllerAnimatedTransitioning)。所以,我只是在檢查:如果它正在呈現 - 我正在做一個動畫(放大第一個和第二個視圖),如果它正在解散 - 我正在做另一個動畫(縮小第一個和第二個視圖)。目前動畫效果良好,出現解散動畫時出現問題。在某種程度上,當我縮小我的第二個控制器(它是UINavigationController)時,我看到背後有黑色背景(這是錯誤的,因爲我想在縮小時看到我的第一個控制器)。這裏是我的代碼從第一控制器ios 7自定義目前和解僱過渡
- (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext {
UIView *transitionView = [transitionContext containerView];
id toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
id fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
BOOL isPresenting;
isPresenting = [toViewController isKindOfClass:[UINavigationController class]];
UINavigationController *navigator = isPresenting ? toViewController : fromViewController;
if (isPresenting) {
[transitionView addSubview:navigator.view];
navigator.view.transform = CGAffineTransformMakeScale(0.1, 0.1);
navigator.view.alpha = 0;
}
navigator.view.center = self.startButton.center;
void(^AnimationBlock)(void) =^{
if (isPresenting) {
navigator.view.transform = CGAffineTransformMakeScale(1, 1);
self.view.transform = CGAffineTransformMakeScale(4, 4);
navigator.view.alpha = 1;
self.startButton.alpha = 0;
} else {
navigator.view.transform = CGAffineTransformMakeScale(0.1, 0.1);
self.view.transform = CGAffineTransformMakeScale(1, 1);
navigator.view.alpha = 0;
self.startButton.alpha = 1;
}
};
[UIView animateWithDuration:1
delay:0.0f
usingSpringWithDamping:50.0
initialSpringVelocity:4
options:UIViewAnimationOptionLayoutSubviews
animations:^{
AnimationBlock();
} completion:^(BOOL finished) {
[transitionContext completeTransition:YES];
if (!isPresenting) {
[navigator.view removeFromSuperview];
}
}];
}
- (void)completeTransitionInContext:(id<UIViewControllerContextTransitioning>)transitionContext{
[transitionContext completeTransition:YES];
}
- (NSTimeInterval)transitionDuration:(id<UIViewControllerContextTransitioning>)transitionContext{
return 1;
}
- (id <UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source {
return self;
}
- (id <UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed {
return self;
}
請告訴我,如果我應該提供一些額外的代碼或屏幕。 在此先感謝!
iOS 7 API仍然處於NDA之下,直到公開發布(18 sept) – Vinzzz
我有一個非常類似的問題,iOS7 API不再處於NDA之下......請你解釋一下如何解決它?謝謝! – veducm
仍然不知道答案:( –