0

I've sample code for the reference which works fine prior iOS 26 but not in iOS 26.

class SampleViewController: UIViewController {
 override func viewDidLoad() {
 super.viewDidLoad()
 
 let aTitleView = UIView()
 aTitleView.backgroundColor = .gray
 aTitleView.translatesAutoresizingMaskIntoConstraints = false
 
 navigationItem.titleView = aTitleView
 navigationItem.setHidesBackButton(true, animated: false)
 
 
 navigationController?.edgesForExtendedLayout = .all
 navigationController?.setNavigationBarHidden(false, animated: true)
 navigationController?.navigationBar.shadowImage = UIImage()
 navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
 navigationController?.navigationBar.backIndicatorImage = UIImage()
 navigationController?.navigationBar.backIndicatorTransitionMaskImage = UIImage()
 }
 
 override func viewWillAppear(_ animated: Bool) {
 super.viewWillAppear(animated)
 navigationController?.setNavigationBarHidden(false, animated: false)
 }
}

This view controller is inside a UITabBarController. The app has a UITabBarController as a home screen along with 3 tabs. You can consider the above controller for all 3 tabs.

Can anyone show me exactly where my code is wrong or what is missing?

HangarRash
16.4k5 gold badges29 silver badges63 bronze badges
asked Oct 1 at 9:22
1
  • 1
    Define "doesn't work". You say "This view controller is inside UITabBarController.". Is it in a navigation controller that is in the tab? If not then I am not surprised it isn't working. Commented Oct 1 at 9:58

1 Answer 1

0

For some reason iOS 26 requires explicit size for titleView. Add width and height constraints to aTitleView and it should appear on screen.

answered Oct 2 at 11:47
Sign up to request clarification or add additional context in comments.

1 Comment

Another option, if the title view is a custom view class, is to override the intrinsicContentSize property to return a proper size for the view.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.