Style all UITextFields at once rather than in each ViewController?
ios, objective-c, uitextfield, uitextview
Solution
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.
Problem
I'm trying to style all the textfields like so: ``` CGRect frameRect2 = _lastname_field.frame; frameRect2.size.height = 30; _lastname_field.font = [UIFont fontWithName:@"AppleGothic" size:15]; _lastname_field.frame = frameRect2; _lastname_field.backgroundColor= [UIColor whiteColor]; _lastname_field.layer.cornerRadius = 5.0; [_lastname_field.layer setBorderColor: [[UIColor grayColor] CGColor]]; [_lastname_field.layer setBorderWidth: 1.0]; _lastname_field.clipsToBounds = YES; ``` That field looks great. Only problem is, there are over 50 textfields throughout the app. Is there an easy way to style all of them the same way? Some of them haven't even been synthesize/named. Thanks!