Is there any way to How to Apply global font [new custom font] to whole application in iphone objective-c.
I know that we can use below method to set font for each label
[self.titleLabel setFont:[UIFont fontWithName:@"FONOT_NAME" size:FONT_SIZE]];
But I want to change for whole application. Please help me if anyone know.
Ican's solution with category might be prefered just to save the day. But avoid using category to override existing methods as apple explains: Avoid Category Method Name Clashes
Note also that overriding
-(id) init;
would be safer than overriding-(id)initWithFrame:(CGRect)frame
. You would not face with the problem of not receiving touch events when clicking on a label on UIButtons.Is this what you mean?
In case you want to do it somehow automatically (without using
setFont
on each control), I don't believe it's possible.Apparently to change ALL UILabels altogether you will need to setup a category on UILabel and change the default font. So here's a solution for you:
Create a file CustomFontLabel.h
Create a file CustomFontLabel.m
Now ... in any view controller you want these custom font labels, just include at the top:
That's all - good luck
If you can limit your application – or this particular feature – to iOS 5, there’s a new API coming that lets you skin the default UI very conveniently. I can’t give you details, since they are still under NDA at the time I am writing this. Take a look at iOS 5 beta SDK to find out more.
CustomLabel.h
CustomLabel.m