Domanda

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

È stato utile?

Soluzione

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

Altri suggerimenti

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.

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`.

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top