Can we change Font, Size for all Label by single file?

Hello everyone,

I would like to ask, have any ways to change all Font, Size for Label by single code or an extension file ?

ex: Android have been supported with the XML file (dimens)

Thanks you! :smiley:

Yes you can do it. Either you can create extension of the UILabel and create category method to do it. also you can create a subclass of UILabel and override setFont method.

In that case first create a subclass of UILabel by adding new file and then inherit all UILabel with your subclass that you have created. In subclass create method setFont, in that method set your font with size. (This you can do only in scenario in which you want to set same font and size for all labels.)

One another way to do it is #define macro(args) in one common class.

#define FONT_BOLD(size) [UIFont fontWithName:@"Helvetica-Bold" size:size]
#define FONT_REGULAR(size) [UIFont fontWithName:@"Helvetica-Regular" size:size]

Now use these macro in all over app where you want. In future, If you want another type of font then just change font name in macro it will reflect in all over app.