[英]Create UITextfield With Both Text and Placeholder
I want to create a UITextField
like above image, with both placeholder in left side and name and Text in right side. 我想创建一个如上图所示的UITextField
,在左侧占位符,在右侧命名和Text。 Can someone please tell me how to do this. 有人可以告诉我该怎么做。
You can set this by setting leftView
to the UITextFiled 您可以通过将leftView
设置为UITextFiled来进行设置
You may declared var of IBOutlet for textfield. 您可以为文本字段声明IBOutlet的var。
let textField = UITextField()
or 要么
@IBOutlet weak var textFiled: UITextFiled!
//create label
let lblName = UILabel(frame: CGRect(x: 0, y:0, width: 80, height: 30))
// --- set other properties to label
//set right view to text field
textField.leftView = lblName
textField.leftView wMode = .whileEditing
You can change leftViewMode
of the textField
. 您可以更改textField
leftViewMode
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.