I am adding a textfield to my view like this:
UITextField* tf_email = [[UITextField alloc] initWithFrame:CGRectMake((320-btnImage1.size.width)/2, 170, 175, 35)];
[tf_email setBackgroundColor:[UIColor clearColor]];
[tf_email setBorderStyle:UITextBorderStyleRoundedRect];
[tf_email setClearButtonMode:UITextFieldViewModeWhileEditing];
[tf_email setReturnKeyType:UIReturnKeyDone];
[tf_email setAutocapitalizationType:UITextAutocapitalizationTypeNone];
[tf_email setEnablesReturnKeyAutomatically:NO];
[tf_email setDelegate:self];
[tf_email setOpaque:YES];
tf_email.tag=1;
tf_email.font = TTSTYLEVAR(font);
tf_email.layer.cornerRadius = 10;
tf_email.keyboardType = UIKeyboardTypeEmailAddress;
[tf_email setAutocorrectionType:UITextAutocorrectionTypeNo];
tf_email.placeholder = @"your@email.com";
[self.view addSubview:tf_email];
When I enter long text in to this field, the text and the clear button overlaps. Does any one know how to fix this?
I figured what the issue was. In another file, I had a category defined for UITextField. This category, specified the text area to be very close to the left and right border. That was causing the overlap.
Lesson learnt: When defining categories, we should use separate files so that the modifications are easily detectable.