本文介绍了UITextField 输入文本位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好我正在制作一个像这样的自定义 UITextField :
HelloI'm making a custom UITextField like so :
_textField.borderStyle=UITextBorderStyleNone;
_textField.backgroundColor = _color;
_textField.layer.borderColor = [[UIColor grayColor]CGColor];
_textField.layer.borderWidth = 1.0f;
_textField.layer.cornerRadius = 8.0f;
_textField.font = [UIFont systemFontOfSize:14];
我得到的结果是(图片网址)http://img402.imageshack.us/img402/4330/questionyd.jpg
The result I get is (image url) http://img402.imageshack.us/img402/4330/questionyd.jpg
问题:如何将输入文本稍微向右移动,使其不接触边框?我想我必须定义一些 .frame 属性,但无法确定是哪一个.
Question : How do I move the input text slightly to the right so it doesn't touch the border ?I suppose I must define some .frame property but can't figure which one.
谢谢!路易斯
推荐答案
您可以尝试创建自己的 UITextField
子类并覆盖该方法:
You may try creating your own subclass of UITextField
and override the method:
-(CGRect)textRectForBounds:(CGRect)bounds
设置您自己的边界而不是处理默认值.
Set your own bounds rather then deal with the default.
这篇关于UITextField 输入文本位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!