Can you try these..
- (CGRect)textRectForBounds:(CGRect)bounds {
int margin = 10;
CGRect inset = CGRectMake(bounds.origin.x + bounds.size.width/2, bounds.origin.y, bounds.size.width/2 - margin, bounds.size.height);
return inset;
}
- (CGRect)editingRectForBounds:(CGRect)bounds {
int margin = 10;
CGRect inset = CGRectMake(bounds.origin.x + bounds.size.width/2, bounds.origin.y, bounds.size.width/2 - margin, bounds.size.height);
return inset;
}
(OR)
做这样
// Do any additional setup after loading the view from its nib.
UIView *paddingTxtfieldView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 20, 42)];// what ever you want
txtfield.leftView = paddingTxtfieldView;
txtfield.leftViewMode = UITextFieldViewModeAlways;
txtfield.returnKeyType = UIReturnKeyNext;// if you want to go next textfiled write this otherwise "UIReturnKeyDone"
这个答案解决了我的问题 http://stackoverflow.com/a/15558652/2136812 – 2014-10-01 08:45:41