UITextField 的文本插入? [英] Text inset for UITextField?
本文介绍了UITextField 的文本插入?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想插入 UITextField
的 text.
这可能吗?
推荐答案
覆盖 -textRectForBounds:
只会改变占位符文本的插入.要更改可编辑文本的插图,您还需要覆盖 -editingRectForBounds:
Overriding -textRectForBounds:
will only change the inset of the placeholder text. To change the inset of the editable text, you need to also override -editingRectForBounds:
// placeholder position
- (CGRect)textRectForBounds:(CGRect)bounds {
return CGRectInset(bounds, 10, 10);
}
// text position
- (CGRect)editingRectForBounds:(CGRect)bounds {
return CGRectInset(bounds, 10, 10);
}
这篇关于UITextField 的文本插入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文