I have an option to change the font size of my application from settings. If i change the size from settings, then it should affect all loaded pages in app.
SO I tried "NSNotificationCenter". I just added Observer in all classes , then I will fire notification from settings.
I have function called "updateUI"
-(void)updateUI{
// here I will change font size of all UI controlls
}
Observer is
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateUI) name:"KFontSizeChanged" object:nil];
then I will call like
[[NSNotificationCenter defaultCenter] postNotificationName:@"KFontSizeChanged" object:self];
When Observer observe any new notification , then "updateUI" function will be called. there UI font size will be updated. It works fine , but I want to know Is there any better solution to achieve this
also I have tried following
yourLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
According to this code , I will need iOS7 and above. but I need iOS 5 and above support. also I will need to go to iPhone settings to change size.
Can anyone Please Let me know is there any better solution to achieve this ?
Thanks in advance
0 comments:
Post a Comment