change placeholder color swift

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

4.1
10

                                    myTextField.attributedPlaceholder = NSAttributedString(string: "placeholder text",
                             attributes: [NSAttributedString.Key.foregroundColor: UIColor.white])

4.1 (10 Votes)
0
3.71
7

                                    placeholderLabel.textColor (Swift 4)

_placeholderLabel.textColor (Swift 3 or less)

3.71 (7 Votes)
0
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 placeholdercolor swift textfile placeholder color swift textview placeholder color ios swift placeholder color textfield in swift change placeholder text color in textfield swift storyboard change placeholder text color in textField swift set placeholder color swift placeholder uitextfield swift color placeholder uitextview swift color place holder text color swift 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 set color for placeholder in swift placeholder text field color swift placeholder color ui text field swift swift change textfield placeholder color text field placeholder color swift change placeholder color swift 5 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 swift 5 placeholder color placeholder color change in swift 5 placeholder color change in swift 4 swift placeholder color programatically ios swiftui placeholder color swiftui placeholder color uitextfield placeholder color swift 5 uitextfield placeholder default color swift uitextfield placeholder color swift placeholder text color swift SwiftUI whta is the color of placeholder SwiftUI color of placeholder change placeholder color of textfield in swift placeholder color 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 swift change color of placeholder swift how to change placeholder color of uitextfield in ios swift uitextfield get placeholder color swift change placeholder color textfield swift placeholder string color swift swift placeholder color change color of titleview navigation swift 5 change placeholder color swiftui placeholder text color in swift change UITextView placeholder text color in swift change placeholder text color in swift ListPlaceholder ios change color how to change text field placeholder color in swift textfield placeholder color swiftui placeholder color swift give color to placeholder swift swift uitextfield change placeholder color swift uitextfield placeholder color swiftui textfield placeholder color placeholderTextColor error the text color of the placeholder string swift how to change placeholder text color swiftui placeholder text color swift placeholder text color swift 5 uitext change placehoder color swift 5 how to change the placeholder color text field attributedplaceholder swift swiftui textfield placeholder font textfield swiftui placeholder color how to give all app textfield placeholder color in swift how to set placeholder color for textfield in swift how to placeholder color of textfield in swift uitextfield placeholder color change in swiftui how to darken placeholder text swift changing placeholder color swift swift placeholder text color color changing placeholder color in swift change text field placeholder color swiftui change text field placeholder color swift swift 5 uitextfield placeholder change placeholder text in Swift set white place holder color in swift swiftui change textfield placeholder color change placeholder color swift ui how to change placeholder text color in swift placeholder color uitextfield swift swift ui placeholder color swift change placeholder text color how to change placeholder color in swift swift set placeholder text color swift change colour of placeh 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