-1

I am making a app for a client in my company. The whole app is complete and is already on the app store. But now he wants me to change the font of the labels/textviews or anywhere there is text - to a customized text. Is there any way that I can change font at one place so that it gets changed everywhere in the app?

halfer
  • 19,824
  • 17
  • 99
  • 186

4 Answers4

4

As far as I am aware, there is no magical solution to change the font globally. You can make small classes to do this. For Example, you can change all UILabel fonts by creating a custom UILabel class and changing the font at initWithFrame and awakeFromNib. So looks like you might have to do this for all the ui elements in your app.

But hey, the advantage is. Next time around it will be a breeze to change fonts. We all know how client companies change their minds...

source - How do I set a custom font for the whole application?

Community
  • 1
  • 1
Srikar Appalaraju
  • 71,928
  • 54
  • 216
  • 264
2

I've just found that [[UILabel appearance] setFont:[UIFont fontWithName:@"Open Sans" size:20.0]]; works well

Anton Gaenko
  • 8,929
  • 6
  • 44
  • 39
0

Create a NSString in your app delegate that is accessible to all of the app's classes. This NSString will be the name of your font. Now go through your app and change the font of all of the text to the name in the NSString.

label.font = [UIFont fontWithName:appDelegate.fontName size:12];

Simply set the NSString to whichever font you choose in the app delegate, and everything else will update to that. This should be easier than creating and implementing a UILabel subclass since you are only looking to change one part of one property.

Jack Humphries
  • 13,056
  • 14
  • 84
  • 125
0

You can write macro for font(which will replace either just font name or UIFont object) in .pch file of your project.

#define TextFont [UIFont fontWithName:@"Helvetica" size:13]

and use it in all classes. But all texts that you put using IB or storyboard, you have to manually change font for all through IB or storyboard. You can create IBOutelets for all UI elements now so that next time it will be easy to change font programatically using macro.

Rahul Wakade
  • 4,765
  • 2
  • 23
  • 25