想要设置一个UITextField是单行或多行
没有找到numberOfLines之类的属性
swift uitextfield line
ios – UITextField multiple lines – Stack Overflow
ios – UITextField border for bottom side only in swift – Stack Overflow
[Question] How do I add a line break in a UITextView?:swift
swift uitextview multiline
ios – Make UITextView multiline – Stack Overflow
Swift – 多行文本输入框(UITextView)的用法
[总结]
多行的话,应该用:UITextView
UITextField只支持单行。
当然,也可以通过设置高度是多行的高度,伪装成多行的:
CGRect frameRect = textField.frame; frameRect.size.height = 53; textField.frame = frameRect; |
举例:
后来用了UITextView,但是由于默认的UITextView不带placeholder,所以又去折腾了:
[已解决]swift给UITextView加placeholder
示例代码:
var descTextView:KMPlaceholderTextView var curContactItem:ContactItem init(curContactItem:ContactItem){ self.descTextView = KMPlaceholderTextView() super.init(nibName: nil, bundle: nil) } //2. description textview self.descTextView.font = UIFont.systemFontOfSize(14) self.descTextView.backgroundColor = UIColor.whiteColor() self.descTextView.placeholder = "输入" + curTypeStr + "简述" self.descTextView.delegate = self self.descTextView.layer.borderWidth = 1 self.descTextView.layer.borderColor = UIColor.grayColor().CGColor self.descTextView.layer.cornerRadius = 4 self.view.addSubview(self.descTextView) |
转载请注明:在路上 » [已解决]Swift设置UITextField的行数