在Xcode中将图像添加到UITextField? [英] Add image to UITextField in Xcode?

查看:107
本文介绍了在Xcode中将图像添加到UITextField?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆