Как обновить стиль StatusBar как часть пользовательского перехода
Я использую iOS 7UIviewControllerAnimatedTransitioning
протокол для представления модальногоViewController
с пользовательской анимацией. Анимация работает правильно, однако, я хочу, чтобы недавно представленныйViewController
иметь другой стиль строки состояния, чем нынешний ВК.
Я вижу, что-(UIStatusBarStyle)preferredStatusBarStyle
вызывается на презентациюViewController
(несколько раз на самом деле) и никогда не на вновь представленныхViewController
, Если я удалю пользовательскую анимацию, все в строке состояния будет работать так, как я ожидал.
Есть ли что-то особенное, что мне нужно сделать в моей функции animateTransition для обновления контроллера корневого представления или что-то в этом роде? Я попытался вручную установить строку состояния с помощью[UIApplication sharedApplication] setStatusBarStyle
но это не работает (я думаю, потому что я использую стилизацию строки состояния на основе контроллера представления ios 7).
Это мой код для 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];
}];
}
Любые указатели высоко ценится!