2013-10-02 59 views
0

我在製作滑動菜單。但是,當我滑動打開並滑動關閉時,前視圖控制器的導航欄與系統狀態欄重疊。如何解決與子視圖控制器混淆的重疊狀態欄?

enter image description here

if (should_hide_status_bar) 
{ 
    [[UIApplication sharedApplication] setStatusBarHidden:is_going_to_open withAnimation:(UIStatusBarAnimationSlide)]; 
} 

[UIView animateWithDuration:DURATION delay:0 usingSpringWithDamping:2 initialSpringVelocity:1 options:(0) animations:^ 
{ 
    CGFloat    disp0 = state == AASlideViewControllerSlidingStateClose ? 0 : OPEN_X_POS; 
    CGAffineTransform t1  = CGAffineTransformMakeTranslation(disp0, 0); 

    self.frontViewController.view.transform = t1; 
} 
completion:^(BOOL finished) 
{ 
    self->_flags.is_sliding    = NO; 
    self.view.userInteractionEnabled = YES; 
}]; 

如何解決這一問題?

回答

0

這很簡單,因爲您正在將狀態欄可見性設置在動畫塊之外。將它移到動畫塊中,我們會看到它正常工作。

BOOL const  should_hide_status_bar = _shouldHideStatusBarWhenOpen; 
BOOL const  is_going_to_open  = state == AASlideViewControllerSlidingStateOpen; 

[UIView animateWithDuration:DURATION delay:0 usingSpringWithDamping:2 initialSpringVelocity:1 options:(0) animations:^ 
{ 
    CGFloat    disp0 = state == AASlideViewControllerSlidingStateClose ? 0 : OPEN_X_POS; 
    CGAffineTransform t1  = CGAffineTransformMakeTranslation(disp0, 0); 

    self.frontViewController.view.transform = t1; 

    if (should_hide_status_bar) 
    { 
     [[UIApplication sharedApplication] setStatusBarHidden:is_going_to_open withAnimation:(UIStatusBarAnimationSlide)]; 
    } 
} 
completion:^(BOOL finished) 
{ 
    self->_flags.is_sliding    = NO; 
    self.view.userInteractionEnabled = YES; 
}]; 

enter image description here