We have the same issue with simple hardcoded width value without using UIScreen.main.bounds.width:
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
navigationItem.titleView = UIView(frame: CGRect(x: 0, y: 0, width: 404, height: 40))
}
The frame of the navigationItem.titleView:
iOS 15: iPhone 13 Pro Max:
<UIView: 0x7f85fda14d10; frame = (0 0; 404 40);>
iOS 16: iPhone 13 Pro Max:
<UIView: 0x7f7894f157e0; frame = (0 0; 388 40);>
The result is the same as in the screenshot in the original question
Post
Replies
Boosts
Views
Activity
It is not related to the width provided, I can simply hardcode another big enough value and have the same result:
override func viewDidLoad() {
super.viewDidLoad()
navigationItem.titleView = UIView(frame: CGRect(x: 0, y: 0, width: 404, height: 40))
}
This will result in navigationItem.titleView's frame:
iOS 15 iPhone 13 Pro Max
<UIView: 0x7fb28c10b610; frame = (0 0; 404 40)>
iOS 16: iPhone 13 Pro Max
<UIView: 0x7fe53ef1c3f0; frame = (0 0; 388 40)>