iPhone - UITextView should look like a UITextField

*爱你&永不变心* 提交于 2019-12-06 08:05:32

问题


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:



来源:https://stackoverflow.com/questions/1979384/iphone-uitextview-should-look-like-a-uitextfield

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!