10

I currently use this code to set the titleView of my navigation item:

- (void)viewDidLoad 
{ ...
   UIImage *navbarTitle = [UIImage imageNamed:@"navbartitleview1"];
   UIImageView *imageView = [[UIImageView alloc]initWithImage:navbarTitle];
   self.navigationItem.titleView =imageView;
}

Is there a way I could put this code using UIAppearance?

[UINavigationItem appearance]

is not valid.

djblue2009
  • 1,342
  • 1
  • 17
  • 23
  • 4
    Simply, No. If you're looking into the Header files, properties must be marked with UI_APPEARANCE_SELECTOR. UINavigationItem does also not comply to the UIAppearance protocol. – Karl Jun 27 '12 at 16:35
  • ah,that's what I figured, thanks. – djblue2009 Jun 27 '12 at 18:27

1 Answers1

1

No you wan't be able to do that with UIAppearence, what you can is to have a UIViewController from where all the others UIViewController will inherit. Think way you avoid having to put that code in all your UIViewControllers.

Rui Peres
  • 25,741
  • 9
  • 87
  • 137