0

I am working on an iOS app in Objective-C, and I want to change the status bar color for a specific view controller. I want to achieve this without using conditional checks for different iOS versions, to ensure consistent behavior across different devices and iOS versions.

Here's what I have tried so far:

- (void)viewDidLoad {
    [super viewDidLoad];
    // Other setup code
    
    // Change navigation bar appearance
    self.navigationItem.title = @"Gobierno del estado";
    [self.navigationController.navigationBar setTintColor:[UIColor darkGobernGreenColor]];
    self.navigationController.navigationBar.backgroundColor = [UIColor darkGobernGreenColor];
    self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor whiteColor]};
    self.navigationController.navigationBar.translucent = NO;
    
    // Update status bar color (this is where I need help)
    // ...
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    // Other cleanup code
}

// Other methods...

I want to change the status bar color to a specific color (let's say black) for this view controller. How can I achieve this without using conditional checks for iOS versions? I understand that the behavior of the status bar has changed in iOS 13 and later, and I want a solution that works consistently across different iOS versions.

Any guidance or code examples would be greatly appreciated. Thank you!

HangarRash
  • 7,314
  • 5
  • 5
  • 32
  • check this answer https://stackoverflow.com/questions/26956728/changing-the-status-bar-color-for-specific-viewcontrollers-using-swift-in-ios8 – Chandaboy Aug 09 '23 at 06:38

0 Answers0