Como atualizo o Estilo StatusBar como parte de uma transição personalizada
Estou usando o iOS 7UIviewControllerAnimatedTransitioning
protocolo para apresentar um modalViewController
com uma animação personalizada. A animação funciona corretamente, no entanto, eu quero o recém-apresentadoViewController
ter um estilo de barra de status diferente do VC de apresentação.
O que estou vendo é que-(UIStatusBarStyle)preferredStatusBarStyle
é chamado no PRESENTINGViewController
(várias vezes na verdade) e nunca no recém-apresentadoViewController
. Se eu remover a animação personalizada, tudo na barra de status funcionará como seria de esperar.
Existe algo especial que preciso fazer na minha função animateTransition para atualizar o controlador de exibição raiz ou algo assim? Tentei definir manualmente o statusBar com[UIApplication sharedApplication] setStatusBarStyle
mas não funciona (acho que porque estou usando o estilo da barra de status do ios 7 view controller)
Este é o meu código para 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];
}];
}
Qualquer ponteiro muito apreciado!