I have a problem with SwiftUI. I am creating a list with a navigation bar, and I want to set navigation bar mode to inline, I don't want it to be large which is by default. But when I set navigation bar title mode to inline, the app crashes.
struct User {
var index: Int
var name: String
}
struct ContentView : View {
var users: [User] = [
User(index: 0, name: "Peter"),
User(index: 1, name: "Marko"),
User(index: 2, name: "John")]
var body: some View {
NavigationView {
List(users.identified(by: \.index)) {
UserRow(user: $0)
}
.navigationBarTitle(Text("Users"), displayMode: .inline)
}
}
}
struct UserRow: View {
var user: User
var body: some View {
Text(user.name)
}
}
I suppose that it is a SwiftUI bug.
Does someone know what could be the problem? Thanks in advance.
UINavigationBar.appearance().isTranslucent = false
,navigationBarTitle - displayMode: .inline
and.navigationViewStyle(StackNavigationViewStyle())
combination made crash for me. I gonna removeUINavigationBar.appearance().isTranslucent = false
for now to solve – Rasbora