Style all UITextFields at once rather than in each ViewController?

后端 未结 5 687
情深已故
情深已故 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

    1) If you create your files within your code, I would create a factory class with an interface like that:

    @interface MyTextFieldFactory : NSObject
    + (UITextField*)createStyledTextField;
    @end
    

    2) If you create your TextFields with the Interface Builder, you could write a category on UITextField, that implements only awakeFromNib:. There you make all your customization. This needs no code changes, neither does it need changes within the nib files.

提交回复
热议问题