Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITextField changes font while editing

I am suffering the same problem as here UITextField's custom font changes while in edit mode and could really do with a solution.

I have 4 UITextFields that I assign custom fonts in ViewDidLoad. This works and they look great, however when clicking a field to edit the text the font changes back to default text and when resignedfirstresponder the custom font comes back.

- (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 field works as it should, so there must be something to do with this font file maybe?

like image 349
Darren Avatar asked Feb 20 '12 10:02

Darren


2 Answers

I have found that when I'm setting the UILabel appearance anywhere in the code:

[[UILabel appearance] setFont:MYFONT];

Changing UITextField font only applies to editing text, and not to the text shown in textfield when user is not editing it.

like image 174
Eva Madrazo Avatar answered Sep 22 '22 01:09

Eva Madrazo


I have downloaded that font and tried it in an iPhone app. I also downloaded some other fonts from the internet and tried them as well. I also tried some Mac fonts such as Chalkduster. I also tried 3Dumb. The results every font I tried EXCEPT 2Dumb and 3Dumb worked. Solution: Use another font.

like image 41
dbrajkovic Avatar answered Sep 23 '22 01:09

dbrajkovic