change textfield placeholder color swiftui
//- Custom TextField
// You can always create your own custom Views to use everywhere:
struct CustomTextField: View {
var placeholder: Text
@Binding var text: String
var editingChanged: (Bool)->() = { _ in }
var commit: ()->() = { }
var body: some View {
ZStack(alignment: .leading) {
if text.isEmpty { placeholder }
TextField("", text: $text, onEditingChanged: editingChanged, onCommit: commit)
}
}
}
// usage (TextField with placeholder):
struct ContentView: View {
@State var text = ""
var body: some View {
CustomTextField(
placeholder: Text("placeholder").foregroundColor(.red),
text: $text
)
}
}
Also in Swift:
- how to change background color swift
- create dictionary swift
- swift variable in a string
- switch statements swift
- Link swiftui
- add toggle without text swiftui
- change ui button swift
- swift enum
- swift temporary directory
- remove back button swift
- create alert in swift
- swift allow gesture recognizer over others
- uilabel font size swift
- swift check dictionary has key
- how to make a image flip swift
- swift go to root view controller
- swift reload tableviewcell at index
- swift how to call a function
- swift access appdelegate from viewcontroller
- how to get index path cell collection view from ui longpress gesture swift
- change textfield placeholder color swiftui
- swift switch
- horizontal slide segue swift
- How to set back button text in Swift