Looking at the behavior of the Apple Messages app, it seems they are using a UITextField for the text input.
The behavior of the placeholder with the cursor appearing at the beginning of the placeholder text (essentially overwriting it) is what I'm basing that assumption on. There is no placeholder for a UITextView that I'm aware of.
I know I can easily use a UITextView and add a placeholder with different color and code the placeholder disappearing when the user starts typing. But I was wondering if there is any way at all to program a UITextField that can have it's frame be fixed in width and expand in height wrapping text.
You can not expand UITextFiled's height.
But you can do this using UITextView ,what you have to do is
Instead of UITextFiled , use UITextView and set ScrollEnabled to false , give UITextView top, bottom, leading and trailing constraint.
Give height constraint to UITextView and set its content hugging priority at low.
now your textview will expand according to text which are insert in it.
Yes, you have to add and manage placeholder logic manually
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