How to fade out the status bar while not hiding it

前端 未结 5 1950
無奈伤痛
無奈伤痛 2020-12-13 00:43

iOS Developers will surely knows about the issue about status bar and the famous \"slide/hamburger/drawer\". The issue is well explained here: http://uxmag.com/articles/adap

5条回答
  •  被撕碎了的回忆
    2020-12-13 01:18

    i don't know if it will sove your problem but i got almost the same effect using the SWRevealViewController project. In the appDelegate I've set the delegate method from this class to do this:

    - (void)revealController:(SWRevealViewController *)revealController willMoveToPosition:(FrontViewPosition)position {
    #ifdef DEBUG
        NSArray *teste = @[@"FrontViewPositionLeftSideMostRemoved",@"FrontViewPositionLeftSideMost",@"FrontViewPositionLeftSide",@"FrontViewPositionLeft",@"FrontViewPositionRight",@"FrontViewPositionRightMost",@"FrontViewPositionRightMostRemoved"];
        NSLog(@"%@ %d", teste[position], position);
    #endif
        if (position == FrontViewPositionRight)
            [[UIApplication sharedApplication] setStatusBarHidden:YES  withAnimation:UIStatusBarAnimationFade];
        UINavigationController *frontViewController = (id)revealController.frontViewController;
        frontViewController.navigationBar.centerY += (position == FrontViewPositionRight) ?  20 : 0; //  20 == statusbar heihgt
    }
    
    - (void)revealController:(SWRevealViewController *)revealController didMoveToPosition:(FrontViewPosition)position {
        if (position == FrontViewPositionLeft)
            [[UIApplication sharedApplication] setStatusBarHidden:NO  withAnimation:UIStatusBarAnimationFade];
    }
    

    centerY is a category in the UIView which sets the center.y without dealing the boring part of setting frame variables.

提交回复
热议问题