Text input box like the SMS app on the iPhone

前端 未结 4 1111
星月不相逢
星月不相逢 2021-01-17 21:32

I am having a terrible time trying to get an input box like the one in the SMS app.

Can anyone offer some guidance on how to build one of these and make it look goo

相关标签:
4条回答
  • 2021-01-17 22:08

    Three20 project has a control that should do this for you.

    From the Three20 README:

    TTTextEditor is a UITextView which can grow in height automatically as you type. I use this for entering messages in Facebook Chat, and it behaves similarly to the editor in Apple's SMS app.

    0 讨论(0)
  • 2021-01-17 22:15

    Try Chat Input Sample. It has the similar look and functionality of SMS app.

    0 讨论(0)
  • 2021-01-17 22:17

    I know this is old but for the people that still look at this answer there is now a nice control from Slack that does that called SlackTextViewController.

    0 讨论(0)
  • 2021-01-17 22:19

    You get to do this yourself. Luckily, the UITextField can notify you whenever its text changes using UITextFieldTextDidChangeNotification, and luckily NSString has methods (under the UIKit Additions) that let you get the height of the string given a certain width using boundingRectWithSize:options:attributes:context:, and luckily you can resize a UITextField yourself using frame.

    0 讨论(0)
提交回复
热议问题