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
        )
    }
}

Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
change textfield placeholder color swift uikit textfile placeholder color swift placeholder color textfield in swift change placeholder text color in textfield swift storyboard change placeholder text color in textField swift placeholder uitextfield swift color placeholder uitextview swift color how to change textfield placeholder color in swift placeholder color textfiled in swift how to change placeholder color of textfield in swift swift textfield placeholder color change placeholder color in swift how to change placeholder text color swift placeholder text field color swift placeholder color ui text field swift swift change textfield placeholder color text field placeholder color swift uitextview placeholder color swift uitextFiled placeholder text color swift textfield placeholder color swift change placeholder color in swiftui uitextfield change placeholder color swift swift 5 uitextfield placeholder color placeholder color change in swift 5 uitextfield placeholder color swift 5 uitextfield placeholder default color swift uitextfield placeholder color swift placeholder text color swift change placeholder color of textfield in swift change placeholder color uitextfield swift change placeholder color swift set placeholder color uitextfield swift change color of placeholder in uitextview swift change textfield placeholder color swift swiftui input placeholder color how to change placeholder color of uitextfield in ios swift change placeholder color textfield swift change placeholder color swiftui how to change text field placeholder color in swift textfield placeholder color swiftui placeholder color swift swift uitextfield change placeholder color swiftui textfield placeholder color swiftui placeholder text color swiftui textfield placeholder font textfield swiftui placeholder color uitextfield placeholder color change in swiftui change text field placeholder color swiftui swiftui change textfield placeholder color change placeholder color swift ui swift ui placeholder color swiftui text field placeholder color change textfield placeholder color swiftui
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source