我正在尝试制作一个表单,要求是有一个包含多行的 UItextfield,这意味着,当在一行中输入特定数量的字符时,blip 会移动到下一行,同时在按下 enter 时它应该输入下一行行也是如此。
目前,我正在使用 Xcode 9.4,但它提供了单行文本字段。
最佳答案
我在这段代码中使用了 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
}()
这是结果
关于ios - 具有多行的 UItextField,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52927245/