ios - 具有多行的 UItextField

标签 ios swift uitextfield interface-builder

我正在尝试制作一个表单,要求是有一个包含多行的 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
}()

这是结果

enter image description here

关于ios - 具有多行的 UItextField,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52927245/

相关文章:

ios - 如何使用 xcode 6.2 在越狱设备中调试 iOS 应用程序

swift - 如何实现串行网络调用队列然后在 RxSwift 中处理?

ios - 无法连接到 UITextField

ios - 在 Swift 2.0 中,我如何使标题单元格与 tableview 单元格一起移动

ios - Swift 中的间歇性 fatal error (在展开可选值时意外发现 nil)

ios - 快速在 View Controller 之间滑动

ios - 我可以使用 Stripe 作为我的 iOS 应用程序的支付网关吗?

ios - TableView 不重新加载数据

iphone - 有没有办法确定何时在UITextField中输入语音文本?

ios - iOS在uitextfield中替换char