我正在尝试制作一个表单,要求是有一个多行的UItextfield,这意味着,当在一行中输入特定数量的字符时,点击键也会移动到下一行,它也应该输入下一行。
目前,我使用的是Xcode9.4,但它只提供了一个单行文本字段。
发布于 2019-11-26 05:14:18
我在代码中使用了UITextView:
lazy var commentTextView: UITextView = {
// Create a TextView.
let textView: UITextView = UITextView()
// Round the corners.
textView.layer.masksToBounds = true
// Set the size of the roundness.
textView.layer.cornerRadius = 20.0
// Set the thickness of the border.
textView.layer.borderWidth = 1
// Set the border color to black.
textView.layer.borderColor = UIColor.systemGray.cgColor
// Set the font.
textView.font = UIFont.systemFont(ofSize: 16.0)
// Set font color.
textView.textColor = UIColor.black
// Set left justified.
textView.textAlignment = NSTextAlignment.left
// Automatically detect links, dates, etc. and convert them to links.
textView.dataDetectorTypes = UIDataDetectorTypes.all
// Set shadow darkness.
textView.layer.shadowOpacity = 0.5
// Make text uneditable.
textView.isEditable = true
return textView
}()这就是结果

发布于 2018-10-22 18:35:38
你应该对多行字符串使用UITextView,或者有第三方库可以使用。MultilineTextField
https://stackoverflow.com/questions/52927245
复制相似问题