Landscape Design Issue: Flattened Navigation Bar and Hidden Elements

21 views Asked by At

Hello StackOverflow community,

I'm encountering a design issue with my application in landscape mode. I've attached a screenshot to illustrate the problem: Image

The difficulty arises in the design of the Navigation Bar. I'm using code that customizes the appearance of both the Navigation Bar and the status bar. Here's the code I'm using to update the UI:

- (void) updateUI
{
    self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor whiteColor]};
    [self.navigationController applyCustomNavigationBarStyleWithColor:[UIColor darkGobernGreenColor]
                                                            textColor:[UIColor whiteColor]];
    [self preferredStatusBarStyle];
    [createAccountButton setTitle:createAccountButtonConstant forState:UIControlStateNormal];
    [createAccountButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    createAccountButton.backgroundColor = [UIColor lightGobernRoseColor];
    createAccountButton.clipsToBounds = YES;
    createAccountButton.layer.cornerRadius = createAccountButton.frame.size.height/2.0;
}

And here's the extension used to customize the Navigation Bar:

- (void)applyCustomNavigationBarStyleWithColor:(UIColor *)backgroundColor
                                     textColor:(UIColor *)textColor
{
    [self.navigationBar setBackgroundColor: backgroundColor];
    self.navigationBar.translucent = NO;
    self.navigationBar.tintColor = [UIColor whiteColor];
    if (@available(iOS 13.0, *)) {
        UIWindow *keyWindow = self.view.window;
        if (keyWindow.windowScene.statusBarManager) {
            UIView *statusBar = [UIView new];
            statusBar.frame = keyWindow.windowScene.statusBarManager.statusBarFrame;
            [statusBar setBackgroundColor:backgroundColor];
            [keyWindow addSubview:statusBar];
        }
    }else{
        UIView *statusBar = [[[UIApplication sharedApplication] valueForKey:@"statusBarWindow"] valueForKey:@"statusBar"];
        if ([statusBar respondsToSelector:@selector(setBackgroundColor:)]) {
            statusBar.backgroundColor = backgroundColor;
        }
    }
    
    [self setNeedsStatusBarAppearanceUpdate];
}

The main issue is that when switching to landscape mode, the Navigation Bar seems to be flattened, and elements such as the title and the back button are not visible correctly. Could you provide me with some guidance on what might be causing this problem and how I could resolve it?

this is the xib:

XIB

I truly appreciate your assistance! Thank you in advance.

0

There are 0 answers