Why does the font of my UITextField change when editing?

My UITextField font gets easier when it is being edited, and bolder when editing. These images should illustrate the problem:

EditingNot editing

Can someone explain why this is so and how to stop it?

This is all the code I have for it - first my subclass of UITextField (which just adds fields):

@interface RLTextField : UITextField { } @end @implementation RLTextField - (CGRect)editingRectForBounds:(CGRect)bounds { CGRect editingRect = CGRectMake(bounds.origin.x+35, bounds.origin.y-5, bounds.size.width, bounds.size.height); return editingRect; } - (CGRect)textRectForBounds:(CGRect)bounds { CGRect editingRect = CGRectMake(bounds.origin.x+35, bounds.origin.y-5, bounds.size.width, bounds.size.height); return editingRect; } @end 

And then where it is actually added to my viewController:

 - (void)viewDidLoad { CGRect noteTitleTextFrame = CGRectMake(self.view.bounds.origin.x, self.view.bounds.origin.y+10, self.view.bounds.size.width, 44); RLTextField *textField = [[RLTextField alloc] initWithFrame:noteTitleTextFrame]; self.nameTextField = textField; [textField release]; self.nameTextField.delegate = self; self.nameTextField.borderStyle = UITextBorderStyleNone; self.nameTextField.contentVerticalAlignment = UIControlContentVerticalAlignmentBottom; self.nameTextField.font = [UIFont fontWithName:@"Courier" size:21]; [self.view addSubview:self.nameTextField]; } 
+4
source share
1 answer

checked your code .... and only one word for this WTF ....!
I do not know what is wrong with this, but there is a solution for this, and this

 self.nameTextField.font = [UIFont fontWithName:@"Courier New" size:21]; 


just change the font name. This will work. Smiles :)
By the way, you probably found a mistake, or maybe not that the apple added Courier New.
I dont know...

+4
source

All Articles