Wie aktualisiere ich den StatusBar-Stil als Teil eines benutzerdefinierten Übergangs?
Ich benutze das iOS 7UIviewControllerAnimatedTransitioning
protokoll zur präsentation eines modalsViewController
mit einer benutzerdefinierten Animation. Die Animation funktioniert einwandfrei, ich möchte das aber neu präsentierenViewController
einen anderen Statusleistenstil haben als die präsentierende VC.
Was ich sehe, ist das-(UIStatusBarStyle)preferredStatusBarStyle
wird auf der PRÄSENTATION genanntViewController
(mehrmals in der Tat) und nie auf dem neu vorgestelltenViewController
. Wenn ich die benutzerdefinierte Animation entferne, funktioniert alles in der Statusleiste wie erwartet.
Muss ich in meiner animateTransition-Funktion etwas Besonderes tun, um den Root-View-Controller zu aktualisieren oder so? Ich habe versucht, die Statusleiste mit manuell einzustellen[UIApplication sharedApplication] setStatusBarStyle
aber es funktioniert nicht (ich denke, weil ich das ios 7 view controller-basierte Statusleisten-Styling verwende).
Dies ist mein Code für animateTransition:
- (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext
{
UICollectionViewCell *activeCell;
if ([self.collectionView.visibleCells containsObject:self.cellForActiveIdeaVC]) {
activeCell = self.cellForActiveIdeaVC;
}
UIView *container = transitionContext.containerView;
UIViewController *fromVC = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
UIViewController *toVC = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
UIView *fromView = fromVC.view;
UIView *toView = toVC.view;
CGRect beginFrame;
if (activeCell) {
beginFrame = [container convertRect:activeCell.bounds fromView:activeCell];
} else {
beginFrame = CGRectMake(container.width / 2, container.height / 2, 0, 0);
}
CGRect endFrame = [transitionContext initialFrameForViewController:fromVC];
UIView *move = nil;
if (toVC.isBeingPresented) {
toView.frame = endFrame;
move = [toView snapshotViewAfterScreenUpdates:YES];
move.frame = beginFrame;
} else {
if (activeCell) {
move = [activeCell snapshotViewAfterScreenUpdates:YES];
} else {
move = [fromView snapshotViewAfterScreenUpdates:YES];
}
move.frame = fromView.frame;
[fromView removeFromSuperview];
}
[container addSubview:move];
[UIView animateWithDuration:.5
delay:0
usingSpringWithDamping:700
initialSpringVelocity:15
options:0
animations:^{
move.frame = toVC.isBeingPresented ? endFrame : beginFrame;
}
completion:^(BOOL finished) {
[move removeFromSuperview];
if (toVC.isBeingPresented) {
toView.frame = endFrame;
[container addSubview:toView];
} else {
if (self.cellForActiveIdeaVC) {
self.cellForActiveIdeaVC = nil;
}
}
[transitionContext completeTransition:YES];
}];
}
Alle Hinweise sehr geschätzt!