如何以编程方式初始化 UITextView?
我怎样才能初始化一个漂亮的 UITextView 呢?我有这样一句话:
textView = [[UITextView alloc] initWithFrame:CGRectMake(150, 150, 100, 100)];
但我想让它看起来不错,但我不知道这样做的函数或语法。我希望它能够自动换行,并且我希望角是圆角的。另外,如果用户按键盘上的“返回”键,如何才能使键盘消失。我想让它说“完成”而不是“返回”
How can I initialize a UITextView that is nice and pretty. I have the line:
textView = [[UITextView alloc] initWithFrame:CGRectMake(150, 150, 100, 100)];
but I'd like to make it look nice and I do not know the functions or the syntax to do so. I'd like it to have word wraping and I'd like the corners to be rounded. Also, how can I make it so that the keyboard goes away if the user presses "Return" on the keyboard. And I'd like to make it say "Done" instead of "Return"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您应该检查文档。这一切都在那里。具体来说:
您可能需要考虑使用 UITextField,因为该对象的委托有一个非常方便的 -textFieldShouldReturn: 方法,并且正如我所说,您可以设置其边框。
You should check the documentation. This is all in there. Specifically:
You might want to consider using a UITextField, as that object's delegate has a very convenient -textFieldShouldReturn: method, and you can, as I said, set its border.
查看 UITextView 文档链接的 UItextInputTraits 协议。
所有这些属性都可以在那里找到,还有其他。
前任:
check out the UItextInputTraits protocol that is linked from the UITextView documentation.
All of these properties can be found there, and others.
EX:
要使边框看起来接近 UITextField,您可以添加以下行。
要通过按“完成”(“返回”)按钮释放键盘,您可以重写以下协议(UITextViewDelegate)方法。
To make the border look close to a UITextField, you can add the following lines.
To release the keyboard by pressing 'Done'('Return') button, you can override the following protocol (UITextViewDelegate) method.