I’m trying to write a mobile substrate tweak to modify the default font color used by application in UINavigationBar title and buttons,
e.g. Instead of default white Title in the Navbar all white navbar text would turn to red,
Hope that is making sense.
At the moment I’m trying:
%hood UINavigationBar
-(void)setTitleView:(id)arg1 {
%orig
UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, 30)];
titleLabel.textColor = [UIColor redColor]
}
%end
I feel its because I’m trying to set a new UILabel rather than replacing the default setTitleView that is pulled.
Any help will be greatly appreciated 🙂
Thanks in advance !
In iOS 5+ there is a new way to do this using the UIAppearance protocol. There’s a good tutorial about how to use it here.
If you need to support iOS 4 still, you can create a subclass of
UIViewControllerand override the variousinit*methods to set properties when the class is created or inviewDidLoadandviewWillAppearetc.. All your controllers can then inherit from this instead ofUIViewControllerdirectly.There are other ways to do this such as adding category methods on
UIViewControlleror swizzling its methods – but I think the above is the simplest.