首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >具有多行的UItextField

具有多行的UItextField
EN

Stack Overflow用户
提问于 2018-10-22 18:32:22
回答 2查看 7K关注 0票数 3

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

目前,我使用的是Xcode9.4,但它只提供了一个单行文本字段。

EN

回答 2

Stack Overflow用户

发布于 2019-11-26 05:14:18

我在代码中使用了UITextView:

代码语言:javascript
复制
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
}()

这就是结果

票数 3
EN

Stack Overflow用户

发布于 2018-10-22 18:35:38

你应该对多行字符串使用UITextView,或者有第三方库可以使用。MultilineTextField

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52927245

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档