HomeiOS DevelopmentView controller title shade not inverting primarily based on background

View controller title shade not inverting primarily based on background


Utilizing Xcode 26.0.1 and operating on iOS Simulator "iPad (A16)" with iOS 26.0.1.

I’m presenting a view controller as Full Display screen in a navigation controller.
It has a leftBarButtonItem, rightBarButtonItem, and a title.
It additionally has a picture view exhibiting a picture with a white background (the picture isn’t full display).

The leftBarButtonItem’s textual content and background colours appear to robotically alter primarily based on the underlying picture shade and light-weight/darkish mode. The title’s textual content shade, nevertheless, doesn’t and solely makes use of the system textual content shade primarily based on mild/darkish mode.

Right here is how the view controller is introduced:

@IBAction func loginPressed(_ sender: Any) {
    let lvc = LoginViewController()
    lvc.delegate = self
    let nc = UINavigationController(rootViewController: lvc)
    nc.modalPresentationStyle = .fullScreen
    self.current(nc, animated: true)
}

Right here is the viewDidLoad of LoginViewController:

override func viewDidLoad() {
    tremendous.viewDidLoad()
    
    self.title = "My Title"
    
    self.view.backgroundColor = .systemBackground
    
    self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "Assist", fashion: .plain, goal: nil, motion: nil)
    
    self.navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .accomplished, goal: self, motion: #selector(doneTapped))
    
    let iv = UIImageView()
    iv.picture = UIImage(named: "ImageWithWhiteBackground")
    iv.contentMode = .scaleAspectFit
    iv.translatesAutoresizingMaskIntoConstraints = false
    self.view.addSubview(iv)
    let wc = NSLayoutConstraint(merchandise: iv, attribute: .width, relatedBy: .equal, toItem: self.view, attribute: .width, multiplier: 1, fixed: 0)
    let hc = NSLayoutConstraint(merchandise: iv, attribute: .top, relatedBy: .equal, toItem: self.view, attribute: .top, multiplier: 1, fixed: 0)
    let xc = NSLayoutConstraint(merchandise: iv, attribute: .centerX, relatedBy: .equal, toItem: self.view, attribute: .centerX, multiplier: 1, fixed: 0)
    let yc = NSLayoutConstraint(merchandise: iv, attribute: .centerY, relatedBy: .equal, toItem: self.view, attribute: .centerY, multiplier: 1, fixed: 0)
    self.view.addConstraints([wc, hc, xc, yc])
}

That is how the view controller seems in Mild Mode in Portrait and Panorama:

View controller title shade not inverting primarily based on background

LightMode Landscape Title visible

The leftBarButtonItem and title textual content colours are darkish as a result of it is Mild Mode — the whole lot is seen and readable.

That is how the view controller seems in Darkish Mode in Portrait and Panorama:

DarkMode Portrait Title visible

The leftBarButtonItem and title textual content colours are mild as a result of it is Darkish Mode — the whole lot is seen and readable. The picture top is lower than the display so the view controller’s view (with background shade set to systemBackground) is seen at high and backside. Discover the leftBarButtonItem is white textual content on a black background (for Darkish Mode).

DarkMode Landscape Title invisible

In panorama, the picture top is the same as the display so it is white at high and backside.
Discover the leftBarButtonItem is now black textual content on a white background (regardless that it is Darkish Mode).
However the title remains to be white making it invisible.
A facet concern is the standing bar can be invisible and unreadable.

Is it doable to make the view controller’s title behave just like the leftBarButtonItem in order that it adjustments colours primarily based on the underlying background?

Or, what’s the urged or really helpful answer for this?

I additionally tried setting self.navigationItem.titleView to a UILabel with "My Title" however that had the identical concern as utilizing self.title.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments