iPhone : HOWTO move status bar with pan gesture

痞子三分冷 提交于 2019-12-18 11:17:23

问题


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.


回答1:


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

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

Then change the frame




回答2:


I don't know why downvote my question without comments or reasons. Though, 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;
        }
    }
}



回答3:


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.




回答4:


And swift:

if let statusBarWindow:UIWindow = UIApplication.shared.value(forKey: "statusBarWindow") as? UIWindow {
   statusBarWindow.frame.origin.y = -5
}


来源:https://stackoverflow.com/questions/25160833/iphone-howto-move-status-bar-with-pan-gesture

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!