0

我正在制作一个滑动菜单。但是当我滑动打开和滑动关闭时,前视图控制器的导航栏与系统状态栏重叠。

在此处输入图像描述

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

如何解决这个问题?

4

1 回答 1

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

在此处输入图像描述

于 2013-10-02T03:41:31.173 回答