UINavigationController highlight color

This simple example, but which does not work,

I have a ViewController where internally on the NavigationConroller, then I want to add a new ViewConroller with its self-navigation controller.

In the main view, the controller:

CustomViewController *vc = [[CustomViewController alloc] init];
NewNavigationVC *nav = [[NewNavigationVC alloc] initWithRootViewController:vc];

[self presentViewController:nav animated:NO completion:nil];

Two controllers have a background color, but black. Navigation Bar I can make a clear, but not a presentation.

UPDATE:

if I change self.window.backroundColor to red, for example, this works, but fuzzy

UPDATE 2:

[self addChildViewController:vc];  
[self.view addSubview:vc.view];
[vc didMoveToParentViewController:self];

and when I want dealloc vc

[vc willMoveToParentViewController:nil];
[vc.view removeFromSuperview];
[vc removeFromParentViewController];

Everything works fine without a navigation controller

+4
source share
2 answers

viewController backgroundColor ( viewController ). viewController viewController viewController.

backgroundColor , :

1) viewController childViewController viewController - .

2) viewController viewController uiview ( ).

+2

. tableViewController:

UITableViewController *modalVC = [UITableViewController new];
UINavigationController *modalNVC = [[UINavigationController alloc] initWithRootViewController:modalVC];

UIViewController *mainVC = [[UIViewController alloc] init];
UINavigationController *mainNVC = [[UINavigationController alloc] initWithRootViewController:mainVC];

modalVC.view.backgroundColor = [UIColor clearColor];
mainVC.view.backgroundColor = [UIColor redColor];
mainNVC.modalPresentationStyle = UIModalPresentationCurrentContext;
[mainNVC presentViewController:modalNVC animated:YES completion:NULL];

, modalPresentationStyle ViewController UIModalPresentationCurrentContext.

, -. . " ", , :

modalVC.view.backgroundColor = [UIColor clearColor];
mainVC.view.backgroundColor = [UIColor redColor];

[mainNVC presentViewController:modalNVC animated:YES completion:^{
    [modalNVC dismissViewControllerAnimated:NO completion:^{
        mainNVC.modalPresentationStyle = UIModalPresentationCurrentContext;
        [mainNVC presentViewController:modalNVC animated:NO completion:NULL];
    }];
}];
+2

All Articles