0

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?

Brian David Berman
  • 7,514
  • 26
  • 77
  • 144

1 Answers1

1

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]];
Animesh
  • 1,020
  • 9
  • 8
  • I think I am looking for something similar to the subclassing of UINavigationBar, but like my original question states, I'm looking for a MonoTouch solution. Thanks. – Brian David Berman Oct 15 '12 at 13:50
  • 1
    Oh sorry I haven't seen MonoTouch and also not much aware of it but the correct way will be subclassing UINavigationBar. – Animesh Oct 16 '12 at 05:00