Reputation: 15
I want to create a UITextField
like above image, with both placeholder in left side and name and Text in right side. Can someone please tell me how to do this.
Upvotes: 0
Views: 117
Reputation: 8914
You can set this by setting leftView
to the UITextFiled
You may declared var of IBOutlet for textfield.
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
.
Upvotes: 1
Reputation: 4356
Try this:
Use a background view, inside that take a label
and a textfield
placed horizontally.
Make sure textField
borderStyle
is none and alignment
right.
Output:
Upvotes: 1