将不可编辑的文本后缀添加到UITextField [英] Adding an uneditable text suffix to a UITextField

查看:90
本文介绍了将不可编辑的文本后缀添加到UITextField的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个UITextField,我想添加一个?输入所有文本的后缀。

I have a UITextField that I'd like to add a "?" suffix to all text entered.

用户不应该删除此?或者在其右侧添加文字。

The user should not be able to remove this "?" or add text to the right hand side of it.

最好的方法是什么?

推荐答案

你'll可能需要继承UITextField并覆盖其 drawText:方法以绘制一个额外的?实际文本右侧的字符。 (而不是实际在视图文本中添加?。

You'll probably need to subclass UITextField and override its drawText: method to draw an additional "?" character to the right of the actual text. (Rather than actually add a "?" to the text of the view.

这篇关于将不可编辑的文本后缀添加到UITextField的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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