Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

How to change uitextfield placeholder text color in swift?


Asked by Jordan Duarte on Dec 13, 2021 Swift



The first argument of the attributed string is the string we want to display, and the second argument is for the attributes we want to use. In the above example we are only using the .foregroundColor attribute and setting it to UIColor.red for simplicity. You could make this any color you want.
Also Know,
Pass the color you want with the attributes: You can accomplish this quickly, without adding a line of code, using Interface Builder. Select the UITextField and open the identity inspector on the right: placeholderLabel.textColor (Swift 4) _placeholderLabel.textColor (Swift 3 or less) Use Color as type and select the color. That's it.
Also, This will allow us to assign an attributed string as the placeholder text. If you do not have the text field as an outlet, you could create a function that will assign the attributed string to the text field as we have done in the code. Using an attributed string is actually quite simple, even if it does seem daunting at first.
Moreover,
Step 1) Add HTML: Use an input element and add the placeholder attribute: Example <input type="text" placeholder="A red placeholder text.."> Step 2) Add CSS: In most browsers, the placeholder text is grey. To change this, style the placeholder with the non-standard ::placeholder selector.
Similarly,
What is Swift MT 110? MT110 Drawing Advices are sent by a Financial Institution that has drawn a Cheque on its account-holding branch, and are received within a Bank.