Set background color for UINavigationBar

I want to develop UINavigationBarand also set the background color for it. I created UINavigationBar, but I have a problem installing backgroundcolor. someone please help me. Thank.

+5
source share
9 answers
[self.navigationController.navigationBar setBackgroundColor:[UIColor redColor]];

Try it. I think it will be useful for you.

Edit: Updated the code to compile.

+14
source

In new iO, this is how it works:

self.navigationController.navigationBar.barStyle  = UIBarStyleBlackOpaque;
self.navigationController.navigationBar.barTintColor =[UIColor colorAzulNavegacion];
+13
source

, (Swift). . , .

, , ( barTintColor, , Apple!) , :

    // Title text color Black => Text appears in white
    UINavigationBar.appearance().barStyle = UIBarStyle.Black

    // Translucency; false == opaque
    UINavigationBar.appearance().translucent = false

    // BACKGROUND color of nav bar
    UINavigationBar.appearance().barTintColor = UIColor.redColor()

    // Foreground color of bar button item text, e.g. "< Back", "Done", and so on.
    UINavigationBar.appearance().tintColor = UIColor.whiteColor()
+6

tint UINavigationBar, . . UIAppearance, UINavigationBar , , , . .

+2

, navbar.tintColor = [UIColor redColor];

: apple docs

+2

:

navigationBar.tintColor = [UIColor blackColor];
+2

self.navigationController?.navigationBar.translucent = false

self.navigationController? .navigationBar.barTintColor = UIColor.redColor ()

self.navigationController? .navigationBar.barStyle = UIBarStyle.BlackTranslucent

+2
source

You can customize UINavigationBarwith the following properties:

  • @property(nonatomic, assign) UIBarStyle barStyle
  • @property(nonatomic, retain) UIColor *tintColor
  • setBackgroundImage:forBarMetrics:
  • @property(nonatomic, copy) UIColor *backgroundColor

For more methods and properties, check the class reference UINavigationBarandUIView

+1
source
self.navigationController.navigationBar.tintColor = [UIColor blackColor];
0
source

All Articles