My code is as follow:
TextField("Enter Your Email", text: self.$username)
How can I make the placeholder "enter your email" be centered in the TextField
?
In most of the browsers, placeholder texts are usually aligned in left. The selector uses text-align property to set the text alignment in the placeholder. This selector can change browser to browser.
To center it vertically, I multiplied the height of the element to 7.5% and make it line-height. Show activity on this post. Show activity on this post. Use the line-height property to make the placeholder vertically centered.
Using the <center></center> tags One way to center text or put it in the middle of the page is to enclose it within <center></center> tags.
TextField("Enter Your Email", text: self.$username)
.multilineTextAlignment(TextAlignment.center)
you can use this code:
yourtextfield.textAlignment = .center
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With