多行 UItextField

May*_*hwa 4 interface-builder uitextfield ios swift

我正在尝试制作一个表单,要求是有一个多行的 UItextfield,这意味着,当在一行中输入特定数量的字符时,blip 也会在按 Enter 键时移动到下一行,它也应该输入下一行。

目前,我正在使用 Xcode 9.4,但它提供了单行文本字段。

Jor*_*ego 5

我将 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
}()
Run Code Online (Sandbox Code Playgroud)

这就是结果

在此输入图像描述