实现思路:
把UITextField的leftView当做填充位置,这样就实现了文字偏移。
代码:
1 UILabel *label = [[[UILabelalloc] initWithFrame:CGRectMake(0, 0, 13, 21)] autorelease]; 2 3 label.backgroundColor = [UIColor clearColor]; 4 5 nickTextField.leftViewMode = UITextFieldViewModeAlways; 6 7 nickTextField.leftView = label;