当我将文本字段设为框时,如何使 UITextField 在 swift 中滚动?
How would I make a UITextField scrollable in swift when I make the text field a box?
我正在为 xcode 中的描述文本框创建一个更大的文本字段,并且我已将文本对齐到框的左上角。但是,当用户键入并到达末尾时,它会离开文本字段并开始向右滚动。我希望文本填满该框,然后在用户填满该框时向下滚动。有什么办法吗?
@IBOutlet weak var questionDirections: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
questionDirections.text = "Please elaborate on your question, the more accurate the description the better!"
questionDirections.textAlignment = .left
}
当我像这样设置文本字段时,我希望它填满该框,然后随着添加更多文本向下滚动,但它向右滚动并且不会像我离开时那样填满该框原始形式的盒子。
改为使用 UITextView:
@IBOutlet weak var questionDirections: UITextView!
override func viewDidLoad() {
super.viewDidLoad()
questionDirections.text = "Please elaborate on your question, the more accurate the description the better!"
}
并且由于语言方向,它的对齐是自动的。
我正在为 xcode 中的描述文本框创建一个更大的文本字段,并且我已将文本对齐到框的左上角。但是,当用户键入并到达末尾时,它会离开文本字段并开始向右滚动。我希望文本填满该框,然后在用户填满该框时向下滚动。有什么办法吗?
@IBOutlet weak var questionDirections: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
questionDirections.text = "Please elaborate on your question, the more accurate the description the better!"
questionDirections.textAlignment = .left
}
当我像这样设置文本字段时,我希望它填满该框,然后随着添加更多文本向下滚动,但它向右滚动并且不会像我离开时那样填满该框原始形式的盒子。
改为使用 UITextView:
@IBOutlet weak var questionDirections: UITextView!
override func viewDidLoad() {
super.viewDidLoad()
questionDirections.text = "Please elaborate on your question, the more accurate the description the better!"
}
并且由于语言方向,它的对齐是自动的。