Hello! I am making an app in SwiftUI and find it hard to make good-looking UIs with SwiftUI when using the List. When having a big navigation bar, the list appears misaligned with the title.
This is a preview within Xcode. Don't know if that changes anything 🤷. Below is the code. I should note I am using Xcode 16 beta 3.
//
// SwiftUIView.swift
//
import SwiftUI
struct SwiftUIView: View {
struct D {
var id: Int
var name: String
var identifier: String
}
let items: [(Int, D)] = [
(0, D(id: 0, name: "Test One", identifier: "one.example.test")),
(1, D(id: 1, name: "Test One", identifier: "two.example.test")),
(2, D(id: 2, name: "Test One", identifier: "three.example.test")),
(3, D(id: 3, name: "Test One", identifier: "four.example.test"))
]
var body: some View {
NavigationStack {
List(items, id: \.1.id) { idx, d in
VStack(alignment: .leading) {
Text(d.name)
.bold()
Text(d.identifier)
}
}
.navigationTitle("Hello Title")
}
}
}
#Preview {
SwiftUIView()
}
Post
Replies
Boosts
Views
Activity
Be warned! When developing your app in Xcode 16 be careful!!! The new SDK has changes that cause builds on Xcode Cloud and other non-beta Xcode to have bugs (EVEN WITH IOS TARGET SET LOWER).
This wasted 2 days of development time, but in WKNavigationDelegate, the webView(_:decidePolicyFor:decisionHandler:) method has a new type signature that will ONLY work in the latest SDK. The change was that the decisionHandler now has a @MainActor attribute. This causes Swift to recognize that it "almost" meets an optional requirement and suggests that you change it. If you change it, it will cause builds to not include the optional method.