I’m trying to specify the buttonStyle-modifier within this SwiftUI-view:
import SwiftUI
struct AddProjectView: View {
@State var projectName = ""
var body: some View {
ZStack {
Color.black
.ignoresSafeArea()
VStack(alignment: .leading) {
Text("New Project")
HStack {
TextField("Project name", text: $projectName)
.textFieldStyle(.roundedBorder)
Button("Save") {
}.buttonStyle(.borderedProminent)
}
}
}
}
}
#Preview {
AddProjectView()
}
There’s no useful auto-completion. Instead the message “This static property is defined on PrimitiveButtonStyle, and may not be available in this context” is shown.
What goes wrong here? Where does this suddenly come from?
The code is fine. It’s working as expected. But I don’t understand the behavior of Xcode.