SwiftUI how to set image for NavigationBar titleView like in UIKit?
问题 I want to set an image in the titleView of NavigationBar in SwiftUI, as we do in UIKit navigationItem.titleView = UIImageView(image: UIImage(named: "logo")) this is how we do it in UIKit. anyone know how to do it? 回答1: Here's how to do it: Add SwiftUIX to your project. Set your custom title view via View.navigationBarTitleView(_:displayMode:) Example code: struct ContentView: View { public var body: some View { NavigationView { Text("Hello World") .navigationBarTitleView(MyView()) } } } 回答2: