문제

I know how to remove the status bar but this automatically snaps my navigation controller and its navigation bar to the top of the screen.

How can I remove the status bar but keep the 20 px space at the top of the screen, so I can put my own custom view or window in that space?

도움이 되었습니까?

해결책

Create a custom UINavigationController and override the viewDidAppear

    - (void)viewDidAppear:(BOOL)animated
    {
        [super viewDidAppear:animated];
        CGRect f = self.view.frame;
        self.view.frame = CGRectMake(0,20,f.size.width,f.size.height-20);
        //the custom view for replacing the status bar.
        //you can add any custom subview you want 
        UIView *iv = [[UIView alloc]initWithFrame:CGRectMake(0,0,320,20)];
        //assign a color with alpha less than 1.0 to make it translucent
        iv.backgroundColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.5];
        //remember to remove the iv when you don't need the navigation controller any more.
        [self.view.window insertSubview:iv aboveSubview:self.view];
    }
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top