<分区>
标签 iphone ios uitextfield
<分区>
我正在开发一个应用程序。根据我的要求,我将文本字段的边框宽度设置为 1o。所以现在文本字段的第一个字符将被边框颜色隐藏。所以请告诉我如何设置光标UITextField 的起始位置。
最佳答案
添加带边框的UIview
,并在UIView
中添加UITextField
UIView *baseView = [[UIView alloc] initWithFrame:CGRectMake(0,0, frame.size.width, frame.size.height)];
[baseView setBackgroundColor:[UIColor clearColor]];
[baseView setUserInteractionEnabled:YES];
[baseView setClipsToBounds:NO];
baseView.layer.borderColor =[UIColor lightGrayColor].CGColor;// UIColorFromRGB(0Xcccccc).CGColor;
baseView.layer.borderWidth = 1.0f;
[self addSubview:baseView];
UITextField* txtField = [[UITextField alloc]initWithFrame:CGRectMake(1, 1, frame.size.width-2, frame.size.height-2)];
[txtField setBackgroundColor:[UIColor whiteColor]];
[baseView addSubview:txtField];
关于iphone - 如何在 UITextField 中设置光标起始位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18910411/