I was wondering if it was possible to change the fonts on about 100 different viewcontrollers all at once? It would be a lot eisier than going through one by one and changing them. Any ideas? Thank you!
The user interface files (*.xib) are plain text and you can load them into an editor.
In Xcode4 on the left pane you can right-click > open as > source.
This will give you the XML source any you can find/replace there.
Warning: doing something wrong may render the whole file useless, so unless you have source control anyway, make copies of the XIB before attempting changes.
you cant change all the fonts at once....
But i have find one more varient that will help you...
I have made some recursive functions thy can help you..
follow following steps..
First create a class(BaseViewController
) extended from UIViewController
like in BaseViewController.h
file
@interface BaseViewController : UIViewController
And in BaseViewController.m
file write following code.
- (void)viewDidLoad
{
[super viewDidLoad];
[self changeFontsOfViewController];
}
-(void)changeFontsOfViewController
{
UIViewController * vv = [self viewControllerOfView:self.view];
NSArray *objects = [[NSBundle mainBundle] loadNibNamed:NSStringFromClass([vv class]) owner:vv options:nil];
for (id object in objects)
{
[self changeFontOfView:object];
}
}
-(void)changeFontOfView:(UIView *)aView
{
for (UIView *vv in [aView subviews])
{
if ([vv isKindOfClass:[UIButton class]])
{
UIButton *btn = (UIButton *)vv;
CGFloat fontSize = btn.titleLabel.font.pointSize;
btn.titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:fontSize];
}
else if ([vv isKindOfClass:[UILabel class]])
{
UILabel *lbl = (UILabel *)vv;
CGFloat fontSize = lbl.font.pointSize;
[lbl setFont:[UIFont fontWithName:@"Helvetica-Bold" size:fontSize]];
}
else if ([vv isKindOfClass:[UITextView class]])
{
UITextView *txt = (UITextView *)vv;
CGFloat fontSize = txt.font.pointSize;
[txt setFont:[UIFont fontWithName:@"Helvetica-Bold" size:fontSize]];
}
else if ([vv isKindOfClass:[UITextField class]])
{
UITextField *txt = (UITextField *)vv;
CGFloat fontSize = txt.font.pointSize;
[txt setFont:[UIFont fontWithName:@"Helvetica-Bold" size:fontSize]];
}
else if ([vv isKindOfClass:[UIView class]]||[vv isKindOfClass:[UIScrollView class]])
{
if (aView.subviews.count == 0)return;
[self changeFontOfView:vv];
}
}
}
Now your every viewController(RootViewController) will be extended from BaseViewController class like in RootViewController.h
..
#import "BaseViewController.h"
@interface RootViewController : BaseViewController
{
}
And make sure that you have written following in your .m
file of your UIViewController
(RootViewController.m
)
- (void)viewDidLoad
{
[super viewDidLoad];
}
Please follow above steps carefully you will rock.......
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With