如何在UITextField中移动清除按钮? [英] How can I move the clear button in a UITextField?

查看:171
本文介绍了如何在UITextField中移动清除按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

出于某种原因,当我将UITextfield添加为tablecell的contentview的子视图时,clearbutton不会与字段中键入的文本对齐,并且会在其下方显示一些内容。有什么方法可以移动clearbutton的文本来阻止这种情况发生吗?感谢您的帮助,

For some reason, when I add a UITextfield as a subview of the contentview of a tablecell, the clearbutton does not align with the text typed in the field, and appears a bit underneath it. Is there any way I can move the text of the clearbutton to stop this from happening? Thanks for any help,

推荐答案

我还没有看到这个,屏幕截图会有所帮助。但是,快速回答是你可以检查UITextField的子视图数组,找到包含clear按钮的子视图,并调整它的frame.origin。

I haven't seen this, and a screen shot would be helpful. But, the quick answer is that you can inspect the subviews array of the UITextField, find the subview that contains the clear button, and adjust its frame.origin.

编辑:看来我已经因为这个答案(2010年写的)而受到了抨击。这不是一个正式批准的方法,因为你正在操纵私人对象,但Apple无法检测到它。主要风险是视图层次结构可能会在某些时候发生变化。

It seems I've been downvoted for this answer (written in 2010). This is of not an "officially" approved method because you're manipulating private objects, but it's not detectable by Apple. The main risk is that the view hierarchy might be changed at some point.

这篇关于如何在UITextField中移动清除按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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