UITextField: textRectForBounds: Vs.编辑RectForBounds: [英] UITextField: textRectForBounds: Vs. editingRectForBounds:

查看:20
本文介绍了UITextField: textRectForBounds: Vs.编辑RectForBounds:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

UITextField 的文本矩形与可编辑文本的区别是什么?

What's the difference between a UITextField's rectangle for its text vs. editable text?

我只想移动文本字段内显示文本的位置.我应该使用相同的确切实现覆盖这两种方法吗?

I just want to move where the text is displayed inside the text field. Should I just override both methods with the same exact implementation?

返回文本字段文本的绘图矩形.

Returns the drawing rectangle for the text field’s text.

返回可以显示可编辑文本的矩形.

Returns the rectangle in which editable text can be displayed.

推荐答案

textRectForBounds: 允许您在未编辑文本字段时设置文本的矩形.

textRectForBounds: lets you set the rectangle for the text when the text field is not being edited.

editingRectForBounds: 允许您在编辑文本字段时设置文本的矩形.

editingRectForBounds: lets you set the rectangle for the text when the text field is being edited.

所以,是的,除非您希望文本在开始时跳转,否则您应该使用完全相同的实现来实现 &结束编辑.

So, yes, you should implement both with the same exact implementation unless you want the text to jump when you begin & end editing.

这篇关于UITextField: textRectForBounds: Vs.编辑RectForBounds:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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