Add image to UITextField in Xcode?
I need to implement the concept of dropdown
in Xcode.
For that purpose, I'm using a UIPickerview
.
This pickerView loads when a textfield is tapped (on textFieldDidBeginEditing:)event.
Question:
Is there a way, that I can add a image to TextField
?
The image is like an arrow mark by which user can understand that a dropdown
appears when textfield
is tapped .How can I make it?
UITextField has a rightView
property, if you have image like this- then You can easly set ImageView object to rightView:
UITextField *myTextField = [[UITextField alloc] init];
myTextField.rightViewMode = UITextFieldViewModeAlways;
myTextField.rightView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"downArrow.png"]];
In Swift:
textField.leftViewMode = UITextFieldViewMode.Always
textField.leftView = UIImageView(image: UIImage(named: "imageName"))