-->

iPhone - UITextView should look like a UITextField

2020-07-22 16:38发布

问题:

I need a textfield so an user could write several lines. Unfortunately a UITextField does not provide several lines, so I think I have to use an UITextView.

But the design of both are not the same.

Is it possible to design the UITextView like the UITextfield standard with white background and rounded corners?

Thanks a lot in advance & Best Regards.

回答1:

In my self appointed role as interface-nazi, I feel compelled to point out that UITextField and UITextView have different appearances to communicate to users to expect a slightly different function.

In a textfield, a return ends editing. In a textview, it may only create a new line. In a textfield, links and phone numbers are not recognized. In a textview they are. Textviews can scroll. And so on...

You shouldn't create a non-standard interface element unless you have a strong compelling reason to do so. You should ask yourself how making a textview look like a textfield will help the user understand what actions they need to take to make the app work as they expect and wish it to.

Surprisingly small tweaks can create serious user confusion. A non-standard interface can introduce just slight pause, a half second, every time they use it. That minor confusion can degrade their perception of the utility of the app.



回答2:

You can put a mask image with rounded borders over your textView. Background of UITextView can be changed by standard setBackgroundColor message.



回答3:

Thanks to Timur here, you can use this chat input sample to implement a multiple line uitextview like what you see in the iPhone messaging app.

It helped me in my app :)

Here how it looks: