I want a ‘+’ Sign in the Textfield which cannot be erased. A user should be able to enter values after it and if he presses backspace it should only erase the v
import SwiftUI
struct ContentView: View {
@State var userName : String = ""
var body: some View {
VStack {
HStack{
Image(systemName: "plus")
TextField("placeholder",text:$userName)
}
.padding(5)
.foregroundColor(.white)
.background(Capsule().fill(Color.gray))
Spacer()
}.padding(5)
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
I will say this is better approach to add "+" sign , so that you will not receive + sign when you access userName