Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add image to UITextField in Xcode?

enter image description here

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?

like image 935
Honey Avatar asked Nov 22 '12 08:11

Honey


People also ask

How do I insert an image into Xcode?

Drag and drop image onto Xcode's assets catalog. Or, click on a plus button at the very bottom of the Assets navigator view and then select “New Image Set”. After that, drag and drop an image into the newly create Image Set, placing it at appropriate 1x, 2x or 3x slot.


1 Answers

UITextField has a rightView property, if you have image like this- enter image description here 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"]];
like image 91
Mayur Birari Avatar answered Sep 20 '22 13:09

Mayur Birari