iOS - 如何使用占位符文本创建UITextView? [英] iOS - How do I create a UITextView with placeholder text?

查看:129
本文介绍了iOS - 如何使用占位符文本创建UITextView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

Placeholder in UITextView


我是iOS的新手,知道如何调用这个英语,但我想创建一些 UITextViews 包含说明或预填充文本,如键入您的名称在这里或键入您的手机 ,等等,用浅色文本编写,但当用户选择文本视图开始输入提示时,它们包含消失。



有任何示例/教程等。

解决方案



div>

有很多方法可以做到这一点。



方法#1:
UITextView没有占位符的属性,所以你必须将text属性设置为您想要的指令,然后一旦用户点击UITextView就可以清除它。



方法#2
某人添加了占位符属性的 UITextView子类


Possible Duplicate:
Placeholder in UITextView

I am relatively new to iOS and I don't know how to call this in english, but I want to create some UITextViews that contain instructions or pre filled text, like "type your name here", or "type your phone", etc, written in light color text but when the user selected the text view to start typing the hints they contain vanish.

Is there any example/tutorial etc. I can follow to learn more about it?

How do I do that in iOS?

解决方案

There are many ways to do this.

Approach #1: UITextView does not have a property for placeholder so you'd have to set the text property to the instructions you would like to have and then as soon as the user taps the UITextView clear it out.

Approach #2 There is a subclass of UITextView that someone made that adds a Placeholder property

这篇关于iOS - 如何使用占位符文本创建UITextView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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