Reputation: 7674
Currently, I am using the following code repeated throughout my application since apparently you aren't supposed to subclass UINavigationController (correct me if I am wrong):
var galleryNavigation = new UINavigationController(galleryDialog);
galleryNavigation.NavigationBar.TintColor = UIColor.FromRGB (33, 114, 131);
galleryNavigation.NavigationBar.Alpha = 0.7f;
galleryNavigation.NavigationBar.Translucent = true;
I want to define these styles (TintColor, Alpha, etc.) once and reuse them. How can I achieve this?
Upvotes: 0
Views: 296
Reputation: 1010
If you just want to set some properties than you can make a method in your AppDelegate or Some shared Class call it from each view controller like
-(void)setNavigation:(UIViewController*)vc
{
//set properties here
}
otherwise if you want more customization than a good option will be to make a subclass of UINavigationBar get inherit it in each view controller as
// Get our custom nav bar
MyNavigationBar* customNavigationBar = (MyNavigationBar*)self.navigationController.navigationBar;
// Set the nav bar's properties as you want like i have set its background image as
[customNavigationBar setBackgroundWith:[UIImage imageNamed:ImgNavBarBackground]];
Upvotes: 1