UITextField changes font during editing

I am experiencing the same problem as here Custom UITextField font changes in edit mode and really can handle the solution.

I have 4 UITextFields that I assigned to custom fonts in ViewDidLoad. This works, and they look great, however, when you click the text edit box, the font returns to the default text, and when the resignedfirstresponder returns, the custom font is returned.

- (void)viewDidLoad { [super viewDidLoad]; { UIFont *twoDumb = [UIFont fontWithName:@"Dumb" size:20.f]; lbl1.font = twoDumb; broughtForward.font = twoDumb; lbl2.font = [UIFont fontWithName:@"Dumb" size:24.f]; amountTextfield.font = twoDumb; lbl3.font = twoDumb; 

If I use system fonts, then the text box works as it should, so there should be something to do with this font file, maybe?

+8
ios fonts iphone uitextfield
source share
4 answers

enter image description here Are the lables you use (lbl1, lbl2, lbl3) customizable or set from an xib file?

I doubt that the font that it changes is due to the font installed in the Xib file.

enter image description here

+1
source share

I found that when I install the appearance of UILabel anywhere in the code:

 [[UILabel appearance] setFont:MYFONT]; 

Changing the UITextField font applies only to text editing, and not to the text shown in the text box when the user does not edit it.

Hope this helps

+3
source share

I downloaded this font and tried it in an iPhone app. I also downloaded some other fonts from the Internet and tried them. I also tried some Mac fonts like Chalkduster. I also tried 3Dumb. The results of each font I tried EXCLUDE 2Dumb and 3Dumb. Decision. Use a different font.

+2
source share

You can set the font again when editing, while editing the font will be the same.

 - (void)textFieldDidBeginEditing:(UITextField *)textField { textField.font = customizedFont; //The font you want to use no matter editing/no editing } 
+1
source share

All Articles