在Xcode中将图像添加到UITextField? [英] Add image to UITextField in Xcode?
问题描述
我需要在Xcode中实现下拉列表
的概念。
I need to implement the concept of dropdown
in Xcode.
为此目的,我使用的是 UIPickerview
。
For that purpose, I'm using a UIPickerview
.
点击文本字段(在textFieldDidBeginEditing :)事件时加载此pickerView。
This pickerView loads when a textfield is tapped (on textFieldDidBeginEditing:)event.
问题:
有没有办法,我可以将图像添加到 TextField
?
Is there a way, that I can add a image to TextField
?
图像就像一个箭头标记,用户可以通过该标记了解时出现
。我该如何制作? 下拉列表
点击了> 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有 rightView
属性 - 然后您可以轻松地将ImageView对象设置为rightView:
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"]];
这篇关于在Xcode中将图像添加到UITextField?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!