9

I am interested to implement left side menu in my application I have used NVSlideMenuController for it. and it works fine.

But I want to modify it. I want to slide status bar with contentViewController and don't want status bar on MenuViewController.

currently it will look like below image

enter image description here

and I want to same as below image

enter image description here

Thanks In advance

Pratik
  • 2,399
  • 15
  • 36
  • 1
    Moving the status bar can be "moved" in effect, but only through some manipulation. See [this SO post](http://stackoverflow.com/a/19011013/2740693) – Christian Di Lorenzo Oct 06 '13 at 22:49
  • 1
    possible duplicate of [Moving status bar in iOS 7](http://stackoverflow.com/questions/19007694/moving-status-bar-in-ios-7) – codercat Feb 28 '14 at 06:16

4 Answers4

11

You can try to turn off your 3G on second image, you will notice that statusBar didn't update.

It seems like a new api in iOS7

[[UIScreen mainScreen] snapshotViewAfterScreenUpdates:NO];

This may be the same question you ask, and there are a demo to show what you want.

Moving status bar in iOS 7

Community
  • 1
  • 1
Chris
  • 428
  • 2
  • 10
2

You may be able to do this by chaining the frame of the keyWindow (you can get this with [[UIApplication sharedApplication] keyWindow] (UIWindow is a subclass of UIView). This should move everything right, and you may need to make another UIWindow to bring other stuff on from the left.

James Snook
  • 4,025
  • 2
  • 15
  • 30
1

You're not going to be able to move the status bar. The best you can do is hide it for that view controller:

- (void) viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];

    if (animated)
    {
        [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
    }
    else
    {
        [[UIApplication sharedApplication] setStatusBarHidden:YES];
    }
}

- (void) viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];

    if (animated)
    {
        [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationSlide];
    }
    else
    {
        [[UIApplication sharedApplication] setStatusBarHidden:NO];
    }
}

Try playing around with the different values of UIStatusBarAnimation to see what looks best. There are three values: UIStatusBarAnimationNone, UIStatusBarAnimationFade, and UIStatusBarAnimationSlide`.

paulrehkugler
  • 3,161
  • 21
  • 44
  • did you see the mailbox application in which status bar is sliding while opening left menu. and I want same things. – Pratik Oct 02 '13 at 09:46
  • There is a property on UIApplication called statusBarFrame ([[UIApplication sharedApplication].statusBarFrame). You could try rendering that to a CG Image Context and creating an image view with that image, then hiding the status bar and moving the image view. That will "fake" the status bar moving, but it won't display dynamic content. – paulrehkugler Oct 02 '13 at 15:11
  • Or you could try hitTest:-ing to try to get the view of the status bar. This is something Apple probably doesn't want you to do, so it will be difficult. – paulrehkugler Oct 02 '13 at 15:12
  • but main problem is this when I hide status bar then My view will get 20px gap between navigation bar and view content. so is there any default control or another solution for it then please suggest me. – Pratik Oct 02 '13 at 16:15
0

This's not an answer but a reply to James's answer because the formatting breaks on comment.

The fact is that setting the frame of the keyWindow will not be able to move the status bar. By setting a break point and printing out the keyWindow recursive description, we'll notice there's no status bar info inside.

(lldb) po [[[UIApplication sharedApplication] keyWindow] recursiveDescription]
<UIWindow: 0x8c5bf80; frame = (0 0; 320 480); gestureRecognizers = <NSArray: 0x8c5c500>; layer = <UIWindowLayer: 0x8c5c0a0>>
   | <UIView: 0x8b49700; frame = (0 0; 320 480); autoresize = W+H; layer = <CALayer: 0x8b496b0>>
(lldb) 

Follow Chris's link to Simon's answer does the job

Community
  • 1
  • 1
James Tang
  • 945
  • 1
  • 9
  • 16