Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you use UIAppearance to set the titleview of UINavigationItem?

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.

like image 384
djblue2009 Avatar asked Jun 27 '12 16:06

djblue2009


People also ask

How do I customize the navigation bar in Swift?

Go to the ViewController. swift file and add the ViewDidAppear method. a nav helper variable which saves typing. the Navigation Bar Style is set to black and the tint color is set to yellow, this will change the bar button items to yellow.

How do I change the navigation bar on my Iphone?

Change the Bar Style A user changes the navigation bar's style, or UIBarStyle , by tapping the “Style” button to the left of the main page. This button opens an action sheet where users can change the background's appearance to default, black-opaque, or black- translucent.

What is a navigation controller?

NavController manages app navigation within a NavHost . Apps will generally obtain a controller directly from a host, or by using one of the utility methods on the Navigation class rather than create a controller directly. Navigation flows and destinations are determined by the navigation graph owned by the controller.


1 Answers

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.

like image 69
Rui Peres Avatar answered Oct 22 '22 14:10

Rui Peres