我有UITextField
我添加了一张图片。
一切看起来都不错,除了文本从零X坐标开始,但我希望它在文本字段中的5个像素之后开始。
答案 0 :(得分:0)
将左视图放入文本字段:
textField.layer.cornerRadius = 5.0;
UIView *paddingView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 5, textField.frame.size.height)];
textField.leftView = paddingView;
[paddingView release];
textField.leftViewMode = UITextFieldViewModeAlways;
答案 1 :(得分:0)
这样做的简单方法。
结帐附加图片以获取详细知识
享受编程!
答案 2 :(得分:0)
最简单的答案:
1)选择一个UIImageView
。在UITextField
中为UIImageView
添加该图片。
2)添加UITextField
“无边框”高于UIImageView
(UIImageView
右侧5个像素)。
GoodLuck !!!
答案 3 :(得分:0)
尝试使用此
UIImageView *imageView = [[UIImageView alloc] init];
// add 5 (width) pixel for your space
imageView.frame = CGRectMake(0,0 ,5, txtFld.frame.size.height);
txtFld.leftViewMode = UITextFieldViewModeAlways;
txtFld.leftView = imageView;
请参阅此图片以获取更多信息。