簡體   English   中英

如何修復與子視圖控制器混淆的重疊狀態欄?

[英]How to fix overlapped status bar which mess with child view controller?

我正在做滑動菜單。 但是,當我滑動打開並滑動關閉時,前視圖控制器的導航欄與系統狀態欄重疊。

在此處輸入圖片說明

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;
}];

如何解決這個問題?

這僅僅是因為您要在動畫塊之外設置狀態欄可見性。 將其移動到動畫塊中,我們將看到它工作正常。

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;
}];

在此處輸入圖片說明

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM