【问题标题】:How to fix overlapped status bar which mess with child view controller?如何修复与子视图控制器混淆的重叠状态栏?
【发布时间】:2013-10-02 03:41:31
【问题描述】:

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

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

如何解决这个问题?

【问题讨论】:

    标签: ios cocoa-touch uinavigationbar ios7 uistatusbar


    【解决方案1】:

    这仅仅是因为您将状态栏的可见性设置在动画块之外。将它移动到动画块中,我们会看到它工作正常。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-08-29
      • 2011-11-22
      • 1970-01-01
      • 1970-01-01
      • 2013-11-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多