Style all UITextFields at once rather than in each ViewController?

后端 未结 5 677
情深已故
情深已故 2021-01-03 00:45

I\'m trying to style all the textfields like so:

CGRect frameRect2 = _lastname_field.frame;
frameRect2.size.height = 30;

_lastname_field.font = [UIFont font         


        
5条回答
  •  天涯浪人
    2021-01-03 01:07

    You should be able to do this for all the properties except the layer stuff...

    in your AppDelegate add a method something like...

    - (void)changeAppearances
    {
        [[UITextField appearance] setFont:[UIFont fontWithName:@"AppleGothic" size:15]];
        [[UITextField appearance] setBackgroundColor:[UIColor whiteColor]];
    }
    

    and so on.

    This will set the appearance for all UITextField instances in your app. (as long as you don't then overwrite them in your code).

提交回复
热议问题