
I want to make a simple form and change the background color of a text field, but Xcode provide me .background(background: View), etc option but not .background(Color()).

I want to make a simple form and change the background color of a text field, but Xcode provide me .background(background: View), etc option but not .background(Color()).
 
    
     
    
    Color is conformed to View. So you can use it like any other View. The issue with your code is you add cornerRadius inside the background modifier. It should be out like this:
TextField("Title", text: .constant("text"))
    .background(Color.red)
    .cornerRadius(5)
 
    
    Try below code.
struct ContentView: View {
   @State var name: String = ""
   var body: some View {
       VStack(alignment: .leading, spacing: 10) {
           Text("NAME").font(.headline)
           TextField("Enter some text", text: $name)
           .padding(.horizontal , 15)
           .frame(height: 40.0)
           .background(Color(red: 239/255, green: 243/255, blue: 244/255))
           .overlay(
               RoundedRectangle(cornerRadius: 5)
                   .stroke(Color.gray.opacity(0.3), lineWidth: 1)
           )
       }.padding(.horizontal , 15)
   }
}
 
    
    import SwiftUI
struct ContentView: View {
    @State var name: String = ""
    var body: some View {
        VStack {
            TextField("Enter some text", text: $name)
                .background(Color.red)
        }
    }
}
 
    
    