Tested in iOS 15.5 simulator
When pushing view controller with navigation bar over one that hasn't navigation bar, contents will be glitchy pinned to left after push animation ends.
Create a new project and replace ViewController.swift:
import SwiftUI
struct SampleView: View {
var navigationBarHidden = false
var body: some View {
Text("I'm gonna glitchy pin to left")
.frame(maxWidth: .infinity, alignment: .leading)
.navigationBarHidden(navigationBarHidden)
}
}
final class ViewController: UIViewController {
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
let navigation = UINavigationController(
rootViewController: UIHostingController(
rootView: SampleView(navigationBarHidden: true)
)
)
navigation.modalPresentationStyle = .fullScreen
present(navigation, animated: false) {
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(1)) {
let hosting = UIHostingController(rootView: SampleView())
navigation.pushViewController(hosting, animated: true)
}
}
}
}