11

Like Instagram - EXPLORE Tab, when I scroll the content, the status bar moves as well.

Always called FullScreenScroll, like here, when the user scrolls the tableView, the NavigationBar & TabBar are scrolled to show or hide at the same time.

My problem is, not only NavigationBar & TabBar, I also want to make the StatusBar follow the finger move.

Finally, it is really fullscreen.

enter image description here

enter image description here

enter image description here

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Jason Lee
  • 3,200
  • 1
  • 34
  • 71

4 Answers4

12

This is the best solution you can find to get status bar window

UIWindow *statusBarWindow = (UIWindow *)[[UIApplication sharedApplication] valueForKey:@"statusBarWindow"];

Then change the frame

Ivan Vavilov
  • 1,520
  • 1
  • 15
  • 28
9

I found a solution to achieve moving status bar.

Thanks to this question and answer which I upvoted for, I can change the statusBar's frame while scrolling like below:

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    NSArray *windows = [[UIApplication sharedApplication] FEX_windows];
    for (UIWindow *window in windows) {
        if ([window isKindOfClass:NSClassFromString(@"UIStatusBarWindow")]) {
            CGRect frame = window.frame;
            frame.origin.y -= 5;
            window.frame = frame;
        }
    }
}
Nimantha
  • 6,405
  • 6
  • 28
  • 69
Jason Lee
  • 3,200
  • 1
  • 34
  • 71
0

You can set the status bar hidden with an animation by calling:

[[UIApplication sharedApplication] setStatusBarHidden:BOOL withAnimation:UIStatusBarAnimation]

If you'd like to move the status bar pixel by pixel, you'll need to take a more creative approach. I believe that the way Instagram does this is by taking an image representation of the status bar (like a screenshot of the status bar), hiding the actual status bar, and then moving the image representation up and down as the user scrolls.

bachonk
  • 3,924
  • 1
  • 14
  • 14
  • 1
    I don't think Instagram use an image to show the status bar, it is complicated to handle many things, like battery change, bluetooth on & off, and so on. I found one way to achieve that yesterday. – Jason Lee Aug 07 '14 at 01:20
  • I'm almost certain it is. You take a screenshot representation of the top bar (it's a snapshot image, so you don't need to worry about the actual contents of the status bar), and you then easily manipulate the image. – bachonk Aug 07 '14 at 14:38
  • 7
    I actually don't think it's a snapshot of the status bar because you can see the time changing during the scroll animation. This wouldn't happen if they just took a single snapshot beforehand. – Michael Waterfall Aug 07 '14 at 22:01
  • Ah ok, good point. I based this assumption on the way Mailbox does this. As you swipe the left menu open and the status bar moves, the time does not change. Instagram must be doing something different. – bachonk Aug 07 '14 at 22:28
0

And swift:

if let statusBarWindow:UIWindow = UIApplication.shared.value(forKey: "statusBarWindow") as? UIWindow {
   statusBarWindow.frame.origin.y = -5
}
Sentry.co
  • 5,355
  • 43
  • 38